If you suspect that a regex isn't parsed the way you wanted it, you can
use re 'debug'; to find out:
$ perl -Mre=debug -wle 'm/C$\n^D/'
Freeing REx: `","'
Omitting $` $& $' support.
EXECUTING...
Compiling REx `C
n^D'
size 6 Got 52 bytes for offset annotations.
first at 1
rarest char D at 3
1: EXACT <C\nn>(3)
3: BOL(4)
4: EXACT <D>(6)
6: END(0)
anchored "C
...
You don't have to understand everything to notice that the
EXACT <C\nn> isn't what you were after.
The literal <c>n has to come from the
...\n in the regex, so the thing before it (a newline) has to come from the previous token in the regex.
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.