Re: A Better Regex
Re: A Better Regex
- Subject: Re: A Better Regex
- From: Emmanuel <email@hidden>
- Date: Sat, 18 Aug 2007 10:01:20 +0200
Tom,
Hope you are well.
At 5:20 PM +1000 8/18/07, T&B wrote:
Did you try the regexp implementation included in Smile? It should
satisfy all your regexp needs.
Does the Satimage OSAX facilitate "non greedy" (eg .*? ) matching
and special escape characters such as \s (for white space
characters)?
I tried using Satimage's "find text" command to replace the
following AppleScript subroutine "GetRegexMatches", which uses do
shell and perl (inefficiently, no doubt), but Satimage doesn't seem
to work with some standard Regexp syntax. Any clues as to how I
could get the GetRegexMatchesOSAX routine below to work the same as
the GetRegexMatches routine, or at least how to get Satimage's "find
text" to handle the full PCRE syntax?
Sorry I was unclear. Satimage.osax and Smile.app implement different stuff.
Satimage implements POSIX regexp (basically, what you find in man
regexp) and works only on MacRoman. Well, it won't choke if you
provide "find text" with Unicode, but it will force the Unicode into
a MacRoman string if you do.
Smile implements POSIX, POSIX_EXTENDED, EMACS, GREP, GNU_REGEX, JAVA,
PERL, and RUBY regexpes, and the regexpes work on Unicode - there are
additional metacharacters to address Unicode sections, for instance.
In Smile, you don't use "find text" and "change", you use "ufind
text" and "uchange".
By default, Smile's regexp is set to RUBY, which allows non-greedy
regexp (.*?) as well as look-ahead and look-behind assertions (e.g.
"first(?!_)" finds "first" only where it's not followed with "_").
As for \s, I'm not sure, neither for "find text" nor for "ufind
text", and I didn't test, personally I use the longer key in the
bottom row of the keyboard :-)
Emmanuel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden