Re: selective string-replace
Re: selective string-replace
- Subject: Re: selective string-replace
- From: "Paul F. Henegan" <email@hidden>
- Date: Wed, 07 Aug 2002 17:53:35 -0400
on 07.08.2002 16:04, email@hidden at email@hidden wrote:
>
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?
Hi Rob,
This works for me:
======================================================================
set inString to "
http://progressive.stream.aol.com/newline/gl/newline/
[NO-BREAK]lordoftherings/TheTwoTowers_480.mov"
set {STR1, STR2, STR3} to {"//", "/", "|"}
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to STR1
set strProt to text item 1 of inString
set strTemp to text item 2 of inString
set AppleScript's text item delimiters to STR2
set strDom to text item 1 of strTemp
set strPth to rest of text items of strTemp
set AppleScript's text item delimiters to STR3
set strPth to strPth as string
set AppleScript's text item delimiters to oldTID
set outString to strProt & STR1 & strDom & STR3 & strPth
--> "
http://progressive.stream.aol.com|newline|gl|newline|lordofthe
[NO-BREAK]rings|TheTwoTowers_480.mov"
======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[
http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]
HTH,
paul
--
Paul F. Henegan
<email@hidden>
_______________________________________________
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.