Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get text between two substrings




On Jun 30, 2005, at 3:11 AM, 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?

A non-optimized, format-dependent, not very robust PCRE [Perl-compatible
reg-ex] (tested in TextWrangler) to grab an HTML comment could be:


Find:     >([^<]*)!
Replace:  \1

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"

set newString to do shell script "echo '" & theString & "' | perl something 'Foo' something 'bar';print"

That clearer?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Re: Get text between two substrings (From: "Gary (Lists)" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.