Re: Detect if third word in string contains a number
Re: Detect if third word in string contains a number
- Subject: Re: Detect if third word in string contains a number
- From: Nigel Garvey <email@hidden>
- Date: Tue, 08 May 2012 22:31:57 +0100
theDaniel wrote on Mon, 07 May 2012 19:43:49 -0400:
>Please tell me about these long numbers. Do you get them from the
>number 12? Would they work for varying numbers? Say, anywhere from 1
>thru 150?
They contain all the numbers from 1 to 120, overlapped so as to require
fewer digits. I derived mine with a simple script:
set digits to ""
repeat with i from 120 to 1 by -1
if digits does not contain (i as text) then set digits to digits & i
end repeat
digits
--> "12011911811711611511411311211111010910810710610510410310210099989796959493929088878685848382807776757473727066656463626055545352504443424033323022"
I then manually removed two unnecessary "1"s from the "11111" sequence
and totally missed the possibility of cutting one digit each from "999",
"888", "777", "666", "555", "444", and "333".
I don't know if Emmanuel derived his excellent string
"10921112010293847566574839301191101181008273645546372811710899011610798
06253443526115106978870114105960423324113104958677685010394022" from
mine or whether he just happened to know a better algorithm. It makes
better use of overlap than mine does and contains thirteen fewer
characters. (It would only be six fewer if I'd noticed "999" etc.) For
obvious reasons, it takes AppleScript slightly less time to locate a
sequence near the beginning of a string than it does one near the end.
SInce the end of Emmanuel's string is slightly nearer its beginning than
is the end of mine, it's use is microscopically faster overall. However,
since his numbers are in a different order from mine, which is faster in
any particular instance depends on the number being tested.
>Regarding example text "I am 12": The first "word" is roman number
>one, two or three ("I", "II" or "III") The second "word" is always an
>english word and the third "word", in this case, is always an arabic
>number, which may vary up to 150. This is not someone's age as
>someone commented earlier. Sorry to confuse the issue.
You might enjoy this:
<http://www.youtube.com/watch?v=oaGpaj2nHIo>
NG
_______________________________________________
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