Me too... I thought you had some escaping problem here, but no. The code in the OP works as intended.
while (<DATA>) {
s/size="10">##ili(\d{1,2})/size="10" text-anchor="end">##ili$1/g;
print;
}
__DATA__
size="10">##ili7
size="10">##ili56
size="10">##iliad
As expected, this prints out
size="10" text-anchor="end">##ili7
size="10" text-anchor="end">##ili56
size="10">##iliad
I.e. it does the replacements on the first two lines, and skips the third as it has a letter instead of a number after the ##ili. I'm not sure what your problem is, perhaps your data isn't as uniform as you thought it was: the source file has variants of the string with whitespace etc. and some of these are not matched by 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.