• 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: selective string-replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: selective string-replace


  • Subject: Re: selective string-replace
  • From: Peter Wiherkoski <email@hidden>
  • Date: Wed, 7 Aug 2002 23:01:27 +0200

>I have a need to write a script that will convert strings like this:
>
>http://progressive.stream.aol.com/newline/gl/newline/lordoftherings/TheTwoTowe
>
>rs_480.mov
>http://progressive.stream.aol.com/wbonline/reloaded_teaser_1_480.mov
>
>into strings like this:
>
>http://progressive.stream.aol.com|newline|gl|newline|lordoftherings|TheTwoTowe
>
>rs_480.mov
>http://progressive.stream.aol.com|wbonline|reloaded_teaser_1_480.mov
>
>I somehow need to do a "search and replace" of the slashes with pipes, yet
>leave the http:// slashes intact. Is there a way I can do a stringreplace,
>yet somehow detect that if there's 2 slashes together, that they should be
>left untouched?
>
>- Rob

NOTE: this QND does not support "theString" to start or end with an "/"

set theString to "http://www.site.se/folder/folder2/index.html";
set items_theString to items in theString
repeat with i from 1 to (count items_theString)

if item i in items_theString is "/" then
if item (i + 1) in items_theString is "/" then
set doSomething to false
else
if item (i - 1) in items_theString is "/" then
set doSomething to false
else
set item i in items_theString to "|"
end if
end if
end if
end repeat
items_theString as string

--

/Peter
_______________________________________________
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.

  • Follow-Ups:
    • Re: selective string-replace
      • From: Michael Grant <email@hidden>
References: 
 >selective string-replace (From: email@hidden)

  • Prev by Date: Re: Quark style and character sheets -- is "normal" always spec number 1?
  • Next by Date: Indesign Applescript wizard anywhere
  • Previous by thread: Re: selective string-replace
  • Next by thread: Re: selective string-replace
  • Index(es):
    • Date
    • Thread