Regular expression escape characters

Ken Ray kray at sonsothunder.com
Thu Mar 29 22:30:59 EDT 2012


On Mar 28, 2012, at 10:19 PM, Bill Vlahos wrote:

> I am building a regular expression to find a set of question marks and exclamation points. For example ??? or !!!.

put "This is a !!! test" into tData
get matchChunk(tData,"(\!{3,})",tStart,tEnd)
put tStart,tEnd
--> 11,13

The "!" is escaped with the backslash (\) and then the use of {3,} means "3 of the previous character", so:

    \!{3,}

matches !!!

Then you surround the match test with parentheses to cause an extraction, and that fills tStart and tEnd with the start and end offsets of the extracted chunk.

You can do the same thing with ?…


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/	




More information about the use-livecode mailing list