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: Emmanuel LEVY <email@hidden>
- Date: Mon, 07 May 2012 21:27:58 +0200
A slightly faster version maybe, just in case:
set _selection to "I am 12"
if (word 1 of _selection is "I") and (word 3 of _selection is in "1092111201029384756657483930119110118100827364554637281171089901161079806253443526115106978870114105960423324113104958677685010394022") then
say "contains a number" using "Bruce"
else
say "contains no numbers" using "Victoria"
end if
Emmanuel
On May 7, 2012, at 5:55 PM, Nigel Garvey wrote:
> 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
_______________________________________________
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