Regular expression escape characters

dunbarx at aol.com dunbarx at aol.com
Thu Mar 29 08:20:56 EDT 2012


I am not sure if this if feasible, but could you replace the problem char with another, one that does not appear in the original text and has no agenda with regex? When you find the chunk data for the substitutes, you can retranslate that back to the original.


So if it is true that "!" is a control char for regex, replace it with, say, numToChar 186, or whatever, do your find on that char, and you will have the correct find info for the original char.


Craig Newman



-----Original Message-----
From: Bill Vlahos <bvlahos at mac.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Wed, Mar 28, 2012 11:22 pm
Subject: Regular expression escape characters


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

These are special characters so they mean something to a regular expression.

How do I find them in the text?

If I want to find a word such as "Bill" I can matchText with (\bBill\b) but I 
can't do (\b!!!\b) and if I do (\b???\b) I get an error.

I've looked on the web for escaping characters and they suggest using a slash 
before. However, when I try (\b\!\!\!\b) it doesn't work.

I've also found references to \Q…\E to have everything between a literal but 
(\b\Q!!!\E\b) doesn't work either.

Any ideas?

Bill Vlahos
_________________
InfoWallet (http://www.infowallet.com) is about keeping your important life 
information with you, accessible, and secure.


_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list