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: Mon, 07 May 2012 16:55:45 +0100
Michelle Steiner wrote on Sun, 06 May 2012 21:05:52 -0700:
>set _selection to "I am 12"
>
>if word 1 of _selection is "I" then
> try
> word 3 of _selection as number
> say "contains a number" using "Bruce"
> on error
> say "contains no numbers" using "Victoria"
> end try
>end if
If one assumes a maximum age of, say, 120, this is slightly faster: ;)
set _selection to "I am 12"
if (word 1 of _selection is "I") and (word 3 of _selection is in "120119118117116115114113112111010910810710610510410310210099989796959493929088878685848382807776757473727066656463626055545352504443424033323022") then
say "contains a number" using "Bruce"
else
say "contains no numbers" using "Victoria"
end if
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