• 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: Is there the equivalent of "any item of"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there the equivalent of "any item of"


  • Subject: Re: Is there the equivalent of "any item of"
  • From: has <email@hidden>
  • Date: Fri, 18 Apr 2008 19:15:26 +0100

On 18 Apr 2008, at 18:22, Thomas Summerall wrote:

Let's say I have a string I want to check for any one of several substrings.

Is there a way to do something like this:

     set stringToSearch to "I have a brand new pair of rollerskates"
     if stringToSearch contains any item of {"new","rollerblade} then
          -- at least one item from the list was found
     end if

I know you can iterate through the list with repeat, I was just wondering about a concise way to do it.


Regular expressions. e.g. Using TextCommands <http://osaxen.com/files/textcommands1.1.3.html >:

	set stringToSearch to "I've got a brand new combine harvester"

	tell application "TextCommands"
		check stringToSearch contains "new|hay baler"
	end tell

If you want only whole-word matches, use:

	tell application "TextCommands"
		check stringToSearch contains "\\b(?:new|hay baler)\\b"
	end tell

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
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
References: 
 >Is there the equivalent of "any item of" (From: Thomas Summerall <email@hidden>)

  • Prev by Date: Deleting "cached" items from the volumes folder
  • Next by Date: Re: Passing argumenst to C executable from Apple script
  • Previous by thread: Re: Is there the equivalent of "any item of"
  • Next by thread: Re: Is there the equivalent of "any item of"
  • Index(es):
    • Date
    • Thread