Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: grep question using multiple lines

by backstab (Novice)
on Dec 28, 2008 at 03:31 UTC ( [id://732865]=note: print w/replies, xml ) Need Help??


in reply to Re: grep question using multiple lines
in thread grep question using multiple lines

My solution with the while loop works with many emails on the same line. In fact doing so we consider the text as a whole totally ignoring newlines.

The idea of /g flag within a while is each match will start where the previous one has stopped and the loop stops when there is no more successful match.

The special variable @- is an array with the match start and end positions respectivly as $-[0] and $-[1] it might help to see what the loop does,

while ($txt =~ /constant=(\w+@\w+\.\w+)/g) { print "==> match starts at $-[0]!!!\n"; print "$1\n"; }

Replies are listed 'Best First'.
Re^3: grep question using multiple lines
by eye (Chaplain) on Dec 28, 2008 at 06:13 UTC
    bradcathey (the OP) wrote:
    I'm trying to isolate some code in BBEdit using the grep functionality offered (Perl friendly).
    By my reading, the OP wants to know how to use the PCRE capability of BBEdit (or TextWrangler) to accomplish this task. While BBEdit has a mechanism for invoking scripts, I do not think that was what the OP was asking about. There are many merits to your answer, but it is not something that can be implemented directly in BBEdit.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://732865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-19 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found