• 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: Get text between two substrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Get text between two substrings (From: Joseph Weaks <email@hidden>)

  • Prev by Date: How to script changing all pdf links from "open in existing window" to "open in new window" throughout a pdf
  • Next by Date: Test to see if web browser can run java script...
  • Previous by thread: Re: Get text between two substrings
  • Next by thread: How to script changing all pdf links from "open in existing window" to "open in new window" throughout a pdf
  • Index(es):
    • Date
    • Thread