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: parsing strings




On Mar 21, 2007, at 17:49, Michelle Steiner wrote:


On Mar 21, 2007, at 2:27 PM, W. Thomas Leroux wrote:

I am trying to figure out how to parse strings like in some other
languages I use - in particular, an applescript equivalent to the
mid(), left() and right() commands.

I've googled around and read through the AppleScript Language Guide,
but I'm not finding what I'm looking for.

Specifically, I'm trying to capture the rightmost character of a string.

set mystring to "Help, I'm caught between these parentheses, and I can't get out"


last character of mystring
character -1 of mystring
character (count of mystring) of mystring

For any arbitrary run of a string
text (startposition) through (endposition) of mystring
For example:

text 3 through 5 of mystring
--> "lp,"

text 13 through end of mystring
--> "ught between these parentheses, and I can't get out"

text 13 through -1 of mystring
--> "ught between these parentheses, and I can't get out"

If you replace "text" in the above with "characters", you get a list:
characters 13 through 22 of mystring
--> {"u", "g", "h", "t", " ", "b", "e", "t", "w", "e", "e"}

-- Michelle

Complementing Michelle's message:

<script>
set mystring to "Help, I'm caught between these parentheses, and I can't get out"


{first character of mystring, middle character of mystring, last character of mystring}
----{"H","p","t"}
</script>



Deivy _______________________________________________ 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 Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Parsing strings (From: "W. Thomas Leroux" <email@hidden>)
 >parsing strings (From: Michelle Steiner <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.