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

Re: What does this regex do?

by pbeckingham (Parson)
on Sep 22, 2006 at 13:16 UTC ( #574370=note: print w/ replies, xml ) Need Help??


in reply to What does this regex do?

Approximation: it captures single lines that do not contain @, and multiple lines (if possible) containing patterns that start and end with @.

Not that it helps much, but here it is in action. Anyone have ideas on what it's trying to find?

#! /usr/bin/perl use strict; use warnings; my $file = do {local $/, <DATA>}; my @cvs = $file =~ /((?:(?:[^\n@]+|@[^@]*@)\n?)+)/gs; print "matched [[$_]]\n" for @cvs; __DATA__ line 1 line 2 line 3 longer @line@ with @some stuff@ line with nothing on it line 4
and the output is:
matched [[line 1 line 2 line 3 longer @line@ with @some stuff@ line with nothing on it ]] matched [[line 4 ]]



pbeckingham - typist, perishable vertebrate.


Comment on Re: What does this regex do?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2015-07-31 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls