• 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: multiple text delimiters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: multiple text delimiters
      • From: "Gary (Lists)" <email@hidden>
  • Prev by Date: Re: Memory leak in Script App
  • Next by Date: Re: multiple text delimiters
  • Previous by thread: Re: multiple text delimiters
  • Next by thread: Re: multiple text delimiters
  • Index(es):
    • Date
    • Thread