• 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
Using perl to extract tagged text - again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using perl to extract tagged text - again


  • Subject: Using perl to extract tagged text - again
  • From: Eric Geoffroy <email@hidden>
  • Date: Wed, 03 May 2006 09:27:02 -0700

This is one of those things that keeps coming back to the list.
First I searched the archives. Found some solutions. Found the sub- routines on Apple's site. I'm probably going to use the subroutine, but for my own education, why isn't my Perl regex working?


I just want to extract any text in between these particular tags- <pre></pre> nothing else. Seems like a simple job for grep! But woe is me to find that grep doesn't have lookaround. Perl does. So I tried this stuff-
(pretend the echo is really curl piped into perl)


My Attempts:
(1)
echo "<pre>sFSwacJX</pre>" | perl -nle 'print if /(?<=<pre>).+(?=</ pre>)/'


(2)
echo "<pre>sFSwacJX</pre>" | perl -nle m/(?<=<pre>).+(?=</pre>)/

(3)
Adam W. once posted something similar to this:
echo "<pre>sFSwacJX</pre>" | perl -ne 'print \"$1\" if m|<pre>(.*?)</ pre>|'"
--> Can't find string terminator '"' anywhere before EOF at -e line 1.


Note: the lookahead and lookbehind works just super in BBedit.
(?<=<pre>).+(?=</pre>)

Thx,

Eric
***********************************************************************
This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. We may monitor email to and from our network.


***********************************************************************


_______________________________________________ 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
  • Follow-Ups:
    • Re: Using perl to extract tagged text - again
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: RE: Good book on advanced AppleScripting?
  • Next by Date: Re: Using perl to extract tagged text - again
  • Previous by thread: Re: Check for already mounted AFP network volume
  • Next by thread: Re: Using perl to extract tagged text - again
  • Index(es):
    • Date
    • Thread