Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manipulate the last item in a string



At 10:04 PM +1000 6/17/06, Marine Themes wrote:
Using applescript with Filemaker I can make a string of found image record names such as this:

"1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg, 6969.jpg."

What I want to do is delete the last comma and insert an "&" into the string to make:

"1234.jpg, 5678.jpg, 4444.jpg, 5555.jpg, 9876.jpg & 6969.jpg."

I assume that I use text item deliminators but not sure how as there are multiple ", " in the string and record names will vary with each use of the script. Any suggestions?

Regular expressions (best implemented in Satimage.osax) are what you need.

Changing the last comma into " &" with regexp is the following command:

set s to change ",([^,]*)$" into " &\\1" in s

Translation: find a comma (','), followed by a sequence of 0, 1 or more ('*') characters which can be anything except comma ('[^,]'), which ends the string ('$'), change that into ' &' followed by the part of the match that I have encapsulated with parentheses.

For a one-time only job, prefer the text item delimiters method as presented by kai.

Emmanuel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Manipulate the last item in a string (From: Marine Themes <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.