• 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: Parsing Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing Strings


  • Subject: Re: Parsing Strings
  • From: Emmanuel <email@hidden>
  • Date: Tue, 18 Dec 2007 00:05:12 +0100

At 4:33 PM -0500 12/17/07, Justin Laden wrote:
What is the best way to parse strings in AppleScript?  I'm hoping to
parse strings in a list and pull out the first 5 letters or numbers,
but only if they lead with a letter and contain 4 following numbers.
Can anyone provide some ideas on parsing strings?  Thanks!

A solution may be to install Satimage.osax (available for free at http://www.satimage-software.com), and use its "find text" command with a regular expression.


find text "^[a-zA-Z][0-9]{4}" in s with regexp

will return a match for a string beginning with (^) one letter ([a-zA-Z]) followed by four ({4}) digits ([0-9]) - and it will error otherwise, so you include it in a try wrapper:

try
	find text blah
	-- found
on error
	-- not found
end

Emmanuel
_______________________________________________
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: 
 >Parsing Strings (From: "Justin Laden" <email@hidden>)

  • Prev by Date: Re: trouble with weekday names
  • Next by Date: Re: trouble with weekday names
  • Previous by thread: Re: Parsing Strings
  • Next by thread: Re: AppleScript-Users Digest, Vol 4, Issue 654
  • Index(es):
    • Date
    • Thread