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: Thu, 02 Aug 2007 10:11:06 -0500
- Thread-topic: Help with find text command
Hi Ed,
Thanks for the input.
I did start out with a vanilla AppleScript approach, but discovered that I
had some concerns about that route (some of which are echoed in your
solution below). First, I was concerned that examining every word in a
repeat loop would be too slow. There is a fair amount of extraneous text
that would be examined word by word unnecessarily and slow things down. So I
thought of regular expressions and wondered if that would be a faster way of
building the list of ISBNs. I remembered Emmanuel posting on this list some
time back, that regular expressions were available in the Satimage osax.
Since I couldn't think of how to get vanilla AppleScript to give the sort of
analytical flexibility you get in regular expressions (at least not without
drastically slowing things down), I gave Satimage a try. Your suggestion of
checking the length of the word, would certainly weed out most of the red
herrings (although the length it would need to test for is 13, because there
are 10 digits and 3 hyphens in a 10 digit ISBN). But then trying to convert
the word into an integer wouldn't work because of the hyphens and even if
you got rid of the hyphens, some ten digit ISBNs have the letter 'X' as the
final digit. So that would cause some trouble. So regular expressions seems
the answer.
I have actually avoided shell scripting on this project because I'm fairly
ignorant in that area and, although I'm always eager to learn new things,
I'm kind of in a rush on this project. So Satimage osax and it's regexp
implementation seems like a good route to me.
--
B!ll
> From: "Stockly, Ed" <email@hidden>
> Date: Wed, 01 Aug 2007 17:01:02 -0700
> To: <email@hidden>
> Subject: Re: Help with find text command
>
> No need for shell scripting or RegEx on this one, William, here's a pure
> AppleScript solution that could get you started.
>
>
>
> set OhMyWord to every word of myText
> Set newNumbers to {}
> repeat with thisWord in OhMyWord
> if the (count of thisWord) = 10 then
> try
> set thisWord to thisWord as integer
> --do routine to convert 10 digit number to 13 digit number
> Set the end of newNumbers to thirteenDigitNumber
> end try
> end if
> end repeat
> Return newNumbers
> HTH,
>
> ES
>
_______________________________________________
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