using the question mark as a quantity qualifier following a character or expression denotes 0 or 1 of those. perl has extensions to the standard regular expressions on systems with sed/awk/grep etc. quite a few of those extensions in perl regex start with a question mark inside brackets. non-greedy matching is with *? quantifier, nothing to do with the previous construct. sometimes you have to be careful with the non-greedy match, as it can also match the zero-width nothingness before the next match, if the next match can eat up the prior characters. the \1 \2 \3 etc match replacements are part of original (unix utilities) regular expression syntax, and are being phased out in perl, in favor of $1 $2 $3 etc. this is because the legacy syntax is only maximum 9 match replacements, i.e. \1 thru \9.
all of these things are departures (extensions) to original (unix) regular expression syntax, and have been with us since perl 5.6 or 5.8. most of the extensions are typically not necessary in a lot of typical day to day work, and hence not widely known/used. it's pretty nice though to come from a unix background to learn perl, and find out that 99% of standard regex syntax applies. a good understanding of even the standard regular expression syntax is a good asset to have.
the hardest line to type correctly is: stty erase ^H
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.