roho has asked for the wisdom of the Perl Monks concerning the following question:
I tried adding the usual pattern for quoted strings ("[^"]+") to the front of the regex alternations but that does not help. I tried adding the limit value of ",3" to split but that also does not help. How can I modify my regular expression (variable $opr_regex) to skip quoted values when splitting the SQL clause?
#!/usr/bin/perl use strict; use warnings; my $clause = qq(failure_reason <> 'Response=X'); my @operators = qw ( <> != !< !> <= >= < > = ); my $opr_regex = '(\s*' . join('\s*|\s*', @operators) . '\s*)'; my ($fld,$opr,$val) = split /$opr_regex/, $clause, 3; print "\n\$opr_regex = $opr_regex\n\n"; print "\$clause = $clause\n\n"; print "\$fld = |$fld|\n"; print "\$opr = |$opr|\n"; print "\$val = |$val|\n\n";
"Its not how hard you work, its how much you get done."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Skip quoted string in regex
by LanX (Saint) on Nov 09, 2015 at 20:21 UTC | |
by Anonymous Monk on Nov 09, 2015 at 21:39 UTC | |
by roho (Bishop) on Nov 09, 2015 at 21:40 UTC | |
|
Re: Skip quoted string in regex
by AnomalousMonk (Archbishop) on Nov 09, 2015 at 20:38 UTC | |
by LanX (Saint) on Nov 09, 2015 at 20:59 UTC | |
by AnomalousMonk (Archbishop) on Nov 09, 2015 at 22:25 UTC |