Re: Help with find text command
Re: Help with find text command
- Subject: Re: Help with find text command
- From: "Wallace, William" <email@hidden>
- Date: Wed, 01 Aug 2007 15:45:14 -0500
- Thread-topic: Help with find text command
Title: Re: Help with find text command
Oops, another wrinkle. The way I have the regexp defined now, I get two matches in the following text:
--
“here is some text with a valid ISBN in it: 0-07-294509-5, and also some gibbberish with a valid ISBN nestled within it: fsdfh123@8X452P340-07-294509-5zzzzzz999999. Now that’s bound to cause trouble.”
--
So, looking at the documentation on Satimage’s website, I see this:
--
Anchors
* ^ (hat) beginning of a line, or the beginning of the selection in a window, or the beginning of the text stored in a variable
* $ end of a line, or the end of the selection in a window, or the end of the text stored in a variable.
* \< beginning of a word
* \> end of a word
* \b beginning or end of a word
* \B strictly within a word
find text "\\bbe" in "tobe or not to be" with regexp
will match the last word.
--
So I can add \b to the beginning and end of each permutation of the pattern, or I can add \< to the beginning and \> to the end of each permutation and both cases seem to work fine. Is there any preferred method? Is one anchor more approriate than the other under certain circumstances. If so, what circumstances? The documentation doesn’t really give any further detail.
Thanks again.
--
B!ll
From: "Mark J. Reed" <email@hidden>
Date: Wed, 1 Aug 2007 15:57:44 -0400
To: "Wallace, William" <email@hidden>
Cc: <email@hidden>
Subject: Re: Help with find text command
On 8/1/07, Wallace, William <email@hidden> wrote:
Mark,
That's all you have to offer? Brute force? ;-}
I know. I need to turn in my Elegant Coders membership card.
Thanks, that will do nicely since it doesn't even need to be that brutal.
The first subgroup of digits will never be more than five and the last
subgroup of digits (since it is the ISBN's check digit) will always be just
a single digit (or it can be the letter x). So I think there are only 25
possible permutations:
Indeed!
Is the ([0-9]|X) syntax okay or is there a more efficient way to say (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, or X)?
You can use just [0-9X] ([0-9Xx] if you want to match both cases of X). The characters between [...] are, in general, the set of possible matches; it's just that the hyphen is treated as a special case so you can enter ranges without having to list all the characters in between.
You only need to break out the | when an alternative is longer than a single character.
--
Mark J. Reed <email@hidden>
_______________________________________________
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