regular expressions and returns

Alex Rice alex at mindlube.com
Fri Sep 12 13:39:01 EDT 2003


On Friday, September 12, 2003, at 10:02  AM, Keith Martin wrote:

> Okay, I'm getting my head around regex (or so I like to pretend), but 
> how would I use replaceText to find/replace a couple of items 
> separated by one or more carraige returns? How do I specify: 'literal 
> string', 'one or more return characters', 'literal string' ..?
>
> As in:
>   <x> (return) <y>
> or
>   <x> (return, return) <y>
> etc...

Like Dar said, newline can be matched with \n

Literal string in regex are just the strings, unless they have special 
regex meanings, then you have to escape them:

"noon\n" would match the word noon followed by a newline. There is are 
multiline and single line modes for the regex engine, but it seems that 
rev's regex functions are always in multiline mode?

check out "PCRE REGULAR EXPRESSION DETAILS" in the URL
http://www.pcre.org/man.txt

In multiline mode, "." means any character except a linefeed.

Also useful might be "\s" which means any whitespace.
"\b" matches at word boundaries

Don't worry, I've been regexing for several years and they are still 
makin' me crazy.


Alex Rice <alex at mindlube.com> | Mindlube Software | http://mindlube.com

what a waste of thumbs that are opposable
to make machines that are disposable  -Ani DiFranco




More information about the use-livecode mailing list