• 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: Removing every instance of a substring
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing every instance of a substring


  • Subject: Re: Removing every instance of a substring
  • From: John Stewart <email@hidden>
  • Date: Tue, 14 Jan 2003 16:58:54 -0500

On Tuesday, January 14, 2003, at 03:04 PM, Gnarlodious wrote:

Does anyone have a handler kicking around that will remove every instance of
a substring from a string?
For example:
"Gnarlodious.util:Workshop.util:Forth.util:Mops.util:MopsManual.util:"

Will morph into:
"Gnarlodious:Workshop:Forth:Mops:MopsManual:"

with removing substring ".util"

Here ya go Rachel


set anyStr to "Gnarlodious.util:Workshop.util:Forth.util:Mops.util:MopsManual.util:"
my doRplc(anyStr, ".util", "")

--> "Gnarlodious:Workshop:Forth:Mops:MopsManual:"


on doRplc(txtStr, srchStr, rplcStr)
set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {srchStr}}
set temp to every text item of txtStr
set AppleScript's text item delimiters to {rplcStr}
set txtStr to temp as text
set AppleScript's text item delimiters to oldDelims
return txtStr
end doRplc

John
_______________________________________________
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: 
 >Removing every instance of a substring (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Removing every instance of a substring
  • Next by Date: Re: Re: unicode escape sequences in AppleScript strings
  • Previous by thread: Re: Removing every instance of a substring
  • Next by thread: NSBorderlessWindow and clearColor
  • Index(es):
    • Date
    • Thread