perl regex modifiers

Alex Rice alrice at ARCplanning.com
Fri Jul 25 18:16:01 EDT 2003


On Friday, July 25, 2003, at 04:23  PM, Mark Brownell wrote:
> If this optimizes in a repeat loop faster than my offset() repeat loop 
> handler, and I'll bet it does, then I can use it for single 
> extractions where there is only one possible instance of a tag-set in 
> the text being searched.

Sounds promising. You can also match without knowing the tag expected, 
using backreferences:

   put "asdf <Sometag>qwertasdsay</someTag> zxcv" into tStr
   put "(?i)<(\w+)>(.+)</\1>" into tRxp
   -- or put "(?i)<(\w+)>([^<>]+)</\1>" into tRxp
   get matchText(tStr, tRxp, tMatch1, tMatch2)
   put tMatch1, tMatch2
   -- says
   -- Sometag,qwertasdsay

In that example the \1 refers to the 1st capture (tMatch1), and uses it 
later in the pattern.

>  There is something funny about all this. Several years ago someone 
> tried to tell me about using Perl regEx to do what I was doing. I 
> didn't think there was a way to do it in Director so I forgot about 
> it. Now it comes back several years later and it does work better, in 
> Rev.

Cool!

Alex Rice, Software Developer
Architectural Research Consultants, Inc.
http://ARCplanning.com




More information about the use-livecode mailing list