4.3.1 A Single Character
4.3.1 A Single Character
The simplest regular expression is a single character expression. For example, when we write /z/, we are looking for the character z.
There are certain characters that are treated as special in Perl. Such characters are preceded by the backslash inside a Perl string. Inside a regular expression, we can use the same backslashed characters, such as \n or \t.
Inside a simple pattern like the ones we have seen so far, we can use the dot character (.) to represent any one character. By default, . does not match \n, but it can be forced to match \n also if needed. Therefore,
/ab.c/
matches the line
The Chinese used abacus to perform simple arithmetic computations.
because abacus contains an a, followed by a b, followed by any single non-newline characters, which happens to be an a here, and then a
c. When a regular expression such as ab.c matches a string, such as the line given above, the match does not have to happen in the beginning. As long as the whole regular expression matches starting at any position before the end of the string, it suffices.
