determining a plain text file

Jim Ault JimAultWins at yahoo.com
Mon Jul 10 20:00:38 EDT 2006


On 7/10/06 4:23 PM, "Mark Smith" <mark at maseurope.net> wrote:
> Not to disparage regexes, but everytime I see one of these neat one-
> line regex solutions on the list, and it's something that I might
> make use of, I seem to find that when used either many times in a
> loop, or just on a lot of data, it turns out be at least quite a lot
> slower than some function that uses Revs chunk expressions/repeat for
> loops.

> I have no idea how efficient the PCRE library is, or how efficiently
> Rev uses that library, but it usually seems to be enough of a
> noticeable difference that I stick with the pure Revolution solution.

The use of RegEx is very powerful in the right place.  The basic idea is
that the PCRE engine will travel through a block of text applying rules
rather than simply doing character comparisons.

Short strings are fast and longer ones exponentially slower.  The reason for
this is usually that RegEx is a way of looking at patterns and character
types/classes rather than specific characters.

I use RegEx frequently when extracting data from web-style published data.
In this case, the data is embedded in formatting instructions called tags.
To write a 'pure Rev solution' would be as much as 30 to 100 lines of code.

I have RegEx working for me all day, every day, and in such a way that it is
very fast, compact, and complex.  However, I just finished a Rev-only data
extractor because it is the right tool for this job.


Jim Ault
Las Vegas





More information about the use-livecode mailing list