Re: Regex in OS X
Re: Regex in OS X
- Subject: Re: Regex in OS X
- From: Emmanuel <email@hidden>
- Date: Sat, 7 Feb 2004 01:43:54 +0100
At 2:04 PM -0800 06/02/04, BJ Terry wrote:
>
It seems that in principle the only thing you need to do is construct an extremely simple regex string, then use one of the many utilities to use it. The regex string would simply be: "^" and the string you're searching for and ".*". This would then be directly useable in either Satimage's osax as
>
>
find text "^Macdonalds.*" in "Macdonalds MacDonalds\ndog" with regexp
>
>
This matches the line "Macdonalds MacDonalds" as Satimage's osax defaults to a "dot doesn't match newline" mode. One could also use this in a do shell script:
>
>
do shell script "grep \"^Macdonalds\" /path/to/file"
>
>
returns every line of the file which begins with Macdonalds. The .* is necessary in Satimage to capture the whole line, but grep defaults to printing the whole line on a match, so it isn't necessary.
In case it's not well known, Satimage's "find text" works on AppleScript variables (which is normal), on Smile's windows (which helps much debugging) and on files (which helps for big texts).
I think there is no significant speed discrepancy between "find text" and "grep". I use grep to *exclude* lines that contain a given pattern, "find text" does not do that.
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.