• 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: String parsing - help!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String parsing - help!


  • Subject: Re: String parsing - help!
  • From: Paul Skinner <email@hidden>
  • Date: Thu, 21 Nov 2002 17:00:25 -0500

On Thursday, November 21, 2002, at 04:36 PM, Emmanuel wrote:

At 11:51 AM -0800 21/11/02, Lui wrote:
There must be an easier way to do the following
parsing...

I have an incoming string '-Name John Smith -Address
123 Home Ave -City San Diego -State California -Zip
92101'

I am trying to capture the values into the
cooresponding fields in FileMaker cells.


Looks like a job for the Regular Expressions:

---------------------------
set s to "-Name John Smith -Address 123 Home Ave -City San Diego -State California -Zip 92101"
matchResult of (find text "-Name (.*) -Address (.*) -City (.*) -State (.*) -Zip (.*)" in s using {"\\1", "\\2", "\\3", "\\4", "\\5"} with regexp)
--> {"John Smith", "123 Home Ave", "San Diego", "California", "92101"}
---------------------------

(using "find text" from the Satimage osax)


I don't know FileMaker well, but I hope you can make something with the list.

Emmanuel
<netiquette> from Satimage-software, the author of the Satimage osax </netiquette>

Or AppleScript :)

set t to "-Name John Smith -Address 123 Home Ave -City San Diego -State California -Zip 92101"

set AppleScript's text item delimiters to "-"
set t to text items 2 thru end of t
set AppleScript's text item delimiters to " "
set tokenList to {}
set valueList to {}

repeat with thisItem in t
set the end of tokenList to text item 1 of thisItem
set the end of valueList to (text items 2 thru end of thisItem) as text
end repeat

{tokenList, valueList}
-->{{"Name", "Address", "City", "State", "Zip"}, {"John Smith ", "123 Home Ave ", "San Diego ", "California ", "92101"}}

--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: String parsing - help! (From: Emmanuel <email@hidden>)

  • Prev by Date: Re: Number of days left in the month
  • Next by Date: Re: Number of days left in the month
  • Previous by thread: Re: String parsing - help!
  • Next by thread: Re: String parsing - help!
  • Index(es):
    • Date
    • Thread