[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The ’.’ isn’t working the way I expected.
Here are some tips for using ‘.’:
-
A common mistake is to place the grouping parenthesis AFTER an operator, when
you really meant to place the parenthesis BEFORE the operator, e.g., you
probably want this
(foo|bar)+
and NOT this(foo|bar+)
.The first pattern matches the words ‘foo’ or ‘bar’ any number of times, e.g., it matches the text ‘barfoofoobarfoo’. The second pattern matches a single instance of
foo
or a single instance ofbar
followed by one or more ‘r’s, e.g., it matches the textbarrrr
. - A ‘.’ inside ‘[]’’s just means a literal‘.’ (period), and NOT “any character except newline”.
-
Remember that ‘.’ matches any character EXCEPT ‘\n’ (and ‘EOF’).
If you really want to match ANY character, including newlines, then use
(.|\n)
Beware that the regex(.|\n)+
will match your entire input! - Finally, if you want to match a literal ‘.’ (a period), then use ‘[.]’ or ‘"."’
This document was generated on November 4, 2011 using texi2html 5.0.