• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detect if third word in string contains a number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Detect if third word in string contains a number
      • From: Emmanuel LEVY <email@hidden>
  • Prev by Date: Re: Detect if third word in string contains a number
  • Next by Date: Re: Adobe Acrobat Pro 10
  • Previous by thread: Re: Detect if third word in string contains a number
  • Next by thread: Re: Detect if third word in string contains a number
  • Index(es):
    • Date
    • Thread