Metacharacters

The Python metacharacters, or special characters and sequences, are listed and described in Tables xref linkend="app05table02" remap="E–2"/> and E-3.

Table E-2. Python Metacharacters (Single Characters)
Metacharacter Behavior Example
.Matches any character except a newline, by default. If the DOTALL flag has been specified, this matches any character, including a newline.
search(".B","AB")
returns a match object

search(".B","A\nB")
returns None
^Matches at the beginning of a string and, if the MULTILINE flag is used, also matches immediately after each newline. Used as the first character of the expression or group to match at the beginning of a string.
search("^cat","cats") returns a match object search("^cat","a cat") ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.