Keep It Simple, Stupid | |
PerlMonks |
Re: Still having trouble with regexes! Please helpby AnomalousMonk (Archbishop) |
on Jan 31, 2016 at 05:45 UTC ( [id://1154103]=note: print w/replies, xml ) | Need Help?? |
Update: The approach discussed in this reply has a problem. Don't use it. For a fix, see my reply below. This needs the Perl version 5.10 regex extensions and defined-or operator, the latter not critical. This approach needs extensive testing to be trusted. (Update: Some more testing done with the test cases used by choroba in his reply in your other thread gives me a bit more confidence in this approach, but you must still thoroughly test!) (Note that my REPL does not like unbalanced single-quote characters, so I use \x27 instead of a single single-quote at one point.) There is probably a more elegant way to express and use these regexes, but it's late... Update 1: From the original value of $x printed above, we have to create the following slightly modified expression, like below:I assume that the single-quote after the !(A & B)' term as quoted from the OP should not be there. If so, please update the OP. Update 2: my $x ='((A & B)\' | (A & C & (A & B & D | (A & (B\' & D)\')\'))';Do yourself a favor and choose a different delimiter when the delimiter character appears in the delimited string: my $x = q{((A & B)' | (A & C & (A & B & D | (A & (B' & D)')'))}; Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|