The regular expression syntax

Any experienced developer has undoubtedly used some kind of regular expression. For instance, in the operating system console, it's not uncommon to find the usage of the asterisk (*) or the question mark (?) to find files.

The question mark will match a single character with any value on a filename. For example, a pattern such as file?.xml will match file1.xml, file2.xml, and file3.xml, but it won't match file99.xml as the pattern expresses that anything that starts with file, followed by just one character of any value, and ends with .xml, will be matched.

A similar meaning is defined for asterisk (*). When asterisk is used, any number of characters with any value is accepted. In the case of file*.xml, anything that ...

Get Mastering Python Regular Expressions now with O’Reilly online learning.

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