Re: Get text between two substrings
Re: Get text between two substrings
- Subject: Re: Get text between two substrings
- From: "Gary (Lists)" <email@hidden>
- Date: Thu, 30 Jun 2005 05:53:55 -0400
"Joseph Weaks" wrote:
> On Jun 30, 2005, Gary (Lists) wrote:
>
>> "Joseph Weaks" wrote:
>>
>>> Given a string, what is a good do shell script one-liner to grab the
>>> text in between two sub-strings?
>>
>> ... grab an HTML comment ...
>>
> No no no no... sorry. I shouldn't have confused the issue by using tags
> in the example. I want to pull the text that falls between to random
> types of strings. Use this example:
>
> set theString to "Foo I'm all that remains Bar"
>> On Jun 30, 2005, "Joseph Weaks" wrote:
>>
>> Would someone recommend a pure Applescript method (offset or TIDs)?
To return the text between 'Foo ' and ' Bar', one could:
set t to "Foo I'm all that remains Bar"
set tClip to item 1 of split({" Bar"}, (the rest of split({"Foo "}, t) as
string)) -- or Unicode text
to split(needle,haystack)
set oTIDs to the text item delimiters
set the text item delimiters to needle
set hay to (text items of haystack)
set the text item delimiters to oTIDs
return hay -- a list
end split
--> "I'm all that remains"
--
Gary
_______________________________________________
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