Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Problem parsing an error msg with regex

by Roger (Parson)
on Oct 07, 2004 at 14:19 UTC ( [id://397311]=note: print w/replies, xml ) Need Help??


in reply to Problem parsing an error msg with regex

Try the following more generic version which strips the first three maximum recursive match of square brackets...

#!/usr/bin/perl -w use strict; my $re; $re = qr/ \[ # Opening bracket (?:(?: # Capture the content and then forget it [^\]\[]+ | (??{$re}) # Or recurse )+) # and allow repeats internally \] # Closing bracket /x; while (my $line = <DATA>) { $line =~ s/($re){3}//g; print $line; } __DATA__ [Microsoft][ODBC SQL Server Driver][SQL Server][0122]USAGE: InvokeStor +edProcedure [param1], [param2], [param3], [param3] [[B1] [B2]][[B3]][B4][B5]Stuff....


And the output is as expected:
[0122]USAGE: InvokeStoredProcedure [param1], [param2], [param3], [para +m3] [B5]Stuff....

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found