Using perl to extract tagged text - again
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