Wild card searches

Alex Rice alrice at ARCplanning.com
Wed Jul 23 17:42:00 EDT 2003


On Wednesday, July 23, 2003, at 04:10  PM, Mark Powell wrote:

> Hi Alex:
>
> Thanks for the pointer.  However, it seems to be treat delimiters 
> funkily,
> assuming only one hit per line.  (e.g. the following returns "apple 
> xxxxx"
> instead of "apple banana carrot xxxxx".
>
> on mouseup
>   put "apple" & tab & \
>       "!nice/!banana" & tab & \
>       "!031110/!carrot" & tab & \
>       "!f/!xxxxx" into myBefore
>   answer replaceText(myBefore, "!.+/!", empty)
> end mouseup
>
> Any ideas?  I want to delete _all_ occurrences of !<whatever>! strings.

You get "apple xxxxx" because the regex I wrote is greedy. You could 
modify the regex so it's not greedy. (I think "greedy" is the term they 
use, but not sure)

"![^!/]+/!"

AHA! That works. So... I guess replaceText() replaces all matches by 
default, which is why it doesn't understand the "(?g)" global 
substitution modifier- it doesn't need to!

Everyone should learn Perl regular expressions :-) It's well worth the 
trouble!

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




More information about the use-livecode mailing list