• 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: Optimizing Character Matching
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimizing Character Matching


  • Subject: Re: Optimizing Character Matching
  • From: Tim Mansour <email@hidden>
  • Date: Sun, 5 Nov 2006 18:02:30 +1100


On 05/11/2006, at 12:39 pm, Rick Gordon wrote:

Does this string contain any character in a list of known bad characters?

OR

Does this string contain any character besides [A-Za-z0-9], and does it begin with a digit?


Both of which are easily accomplished using regular expressions. With Satimage.osax installed:

find text "[ _<>()*~-]" in stringToSearch regexp true

will return a result if one of the characters between the brackets* is in stringToSearch. And:

find text "^[0-9][A-Za-z0-9]+$" in stringToSearch regexp true

will return a result only if stringToSearch is alphanumeric, starting with a digit.

In both cases, the "find text" command throws an error if no match is found. So if you're only interested in a boolean result you could trap for an error in each case. For instance:

try
  find text "[ _<>()*~-]" in stringToSearch regexp true
  set badCharsFound to true
on error
  set badCharsFound to false
end try



*note the hyphen should be last

--
Tim Mansour <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/mailman//archives/applescript-users

This email sent to email@hidden
References: 
 >Optimizing Character Matching (From: Rick Gordon <email@hidden>)
 >Re: Optimizing Character Matching (From: Tim Mansour <email@hidden>)
 >Re: Optimizing Character Matching (From: Rick Gordon <email@hidden>)

  • Prev by Date: Re: Debugging Tool in ASS 2.4
  • Next by Date: Re: App and droplet
  • Previous by thread: Re: Optimizing Character Matching
  • Next by thread: Auto Start FileMaker and open file?
  • Index(es):
    • Date
    • Thread