Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Gurus,
This might be a merely question; but made me to be in perplexed state. The following regular expression I wrote is to validate a self closing tag in the XML. If there is more than one tag in the current line; I would handle in elsif (next line).
#!/usr/bin/perl $line = '<log dest="calllog"> directory <value expr="callRecDirPath"/> +'; if ( $line =~ /<(\w(?:[^ \/>]+))(?:(?:(?:\s+)([^=>]+)\s*=\s*("|')([^\3 +]*)\3))\s*\/>/) { print ("1=" . $1. "\n2=" . $2 . "\n3=" . $3 . "\n4=" . $4 . "\ +n5=" . $5 . "\n"); }
But I got the flowing result:
1=log 2=dest 3=" 4=calllog"> directory <value expr="callRecDirPath
From the above result; the value for 4 is the issue. The value for 3 is "; therefore ([^\3]*) should not have this double quote in its value. But the result 4 has two double quotes. How this happen? Can you please help me in this regard?
Thanks in advance.
G. Indragoby.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PERL Regular expression
by kennethk (Abbot) on Sep 03, 2010 at 18:48 UTC | |
|
Re: PERL Regular expression
by Marshall (Canon) on Sep 03, 2010 at 19:02 UTC | |
by Anonymous Monk on Sep 03, 2010 at 19:53 UTC | |
|
Re: PERL Regular expression
by dasgar (Priest) on Sep 03, 2010 at 18:45 UTC |