I might have encountered
Peculiarities in using
(??{...}) too, and I intended to inquire about them, but didn't want to deal with it yet (guess I'm about to though!). I wanted to match either non-single or non-double quote characters in a regex, depending on which type of quotes surrounded it. For example, since
$var =~ /(["'])[^\1]*?\1/;
doesn't work due to
[^\1] not working, I tried something like
$var =~ /(["'])[^(??{"$1"})]*?\1/;which worked unless $1 contained a special character (forgot the character, but it wasn't a quote), when it gave me an error. I tried various fixes, and finally got
$var =~ /(["'])([^"']|[^(??{"$1"})])*?\1/;to work. I figured the
[^"'] alternative that I added would match the problem character, eliminating the need for parsing the
(??{"$1"}) construct, which had given me the error. Well, it worked until it didn't, for whatever reason. I think I created another patch (placed \Q and \E somewhere), which didn't work consistantly either. Then I spent several hours deleting all of the
(??{...}) constructs and stuck with a simple .*? between the quotes.
I'm just a beginner, so it's possible I did something wrong, but I don't know what.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.