the following may do the trick:
s{ ((?: [^ ]+ \s+ ){17}) \d{1,3} (\s+ \d+) $} {$1$count$2}x;
just a few points, some of which have been made before...
- the complemented character set [^ ] is not the same as \S (that's a capital-S) because it includes the tab, newline, etc., characters -- in fact, all characters (including whitespace characters) except space;
- because the pattern is anchored at the end of the string, the (?: [^ ]+ \s+ ){17} repetitions may be preceded by more (?: [^ ]+ \s+ ) repetitions or by anything else;
- therefore, what you are really saying is that you want the \d{1,3} you're replacing to be preceded by at least 17 repetitions of (?: [^ ]+ \s+ ), then by anything else;
- it may be worth considering if this ``17 repetitions'' business is really what you need;
- if it isn't, the regex may simplify further to s{ \d{1,3} (?= \s+ \d+ $)} {$count}x;
all these regexes are untested.
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.