Re: multiple text delimiters
Re: multiple text delimiters
- Subject: Re: multiple text delimiters
- From: has <email@hidden>
- Date: Wed, 28 Sep 2005 22:53:48 +0100
Patrick J. Collins wrote:
>Is there a way to set applescripts text delimiters to more than one character?
>
>Like if I wanted to remove all characters "[" "]" "(" and ")" from a string?
Using TextCommands <http://freespace.virgin.net/hamish.sanderson/index.html#textcommands>:
tell application "TextCommands"
strip theText using "[]()" from throughout
end tell
For longer sub-strings, you can use a regular expression to strip them all in a single command:
tell application "TextCommands"
search theText for "foo|bar|baz" replacing with "" with regex -- strips "foo", "bar" and "baz"
end tell
The 'split' command also accepts multiple delimiters, if you want to split the string rather than strip it:
tell application "TextCommands"
split theText using {"foo", "bar", "baz"}
end tell
Or with a regular expression:
tell application "TextCommands"
search theText for "foo|bar|baz" finding non matches with regex
end tell
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden