Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Need Regex help

by JediWizard (Deacon)
on Sep 09, 2005 at 16:01 UTC ( [id://490623]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Need Regex help
in thread Need Regex help

#!/usr/local/bin/perl $re = qr@ \{( (?: (?> [^{}]+ ) # Non-{} without backtracking | (??{ $re }) # Group with matching {} )* )\} @x; my $string = 'value:patternList = "{error 1 1 {^E 0-20-9:0-50-9:0-50-9 +.*$} {^E 0-20-9:0-50-9:0-50-9.*$}} {three 1 1 {^.*35=A.*$|^.*35=5.*$} + {^.*35=A.*$|^.*35=5.*$}} {fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*V +FIXFxProxy.*Disconnected}"'; my $count = 1; while($string =~ m/$re/g){ my $inst = $1; my(@elements) = ($inst =~ m/((?<={)[^}]+(?=})|[^\s{}]+)/g); print "Instance $count\'s elements = ".join("\n", @elements)." +\n\n\n"; $count++; } exit; __END__ Instance 1's elements = error 1 1 ^E 0-20-9:0-50-9:0-50-9.*$ ^E 0-20-9:0-50-9:0-50-9.*$ Instance 2's elements = three 1 1 ^.*35=A.*$|^.*35=5.*$ ^.*35=A.*$|^.*35=5.*$ Instance 3's elements = fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*VFIXFxProxy.*Disconnected

Update Removed unnessicary grouping paranethesis.


They say that time changes things, but you actually have to change them yourself.

—Andy Warhol

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-23 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found