re Object Methods and Properties

The sections that follow describe the syntax, use, and arguments of regular expression object methods and properties.

search()

<re object>.search (string[, pos][, endpos])
Table E-1. Optional Flags for Regular Expression Functions
Flag Behavior Example
I (IGNORECASE) Ignore case when searching.
search("^exam","Example",I)
returns a match object
search("^exam","Example")
returns None
L (LOCALE) The metacharacters \w, \W, \b,\B are made to fit the currentlocale.  
M (MULTILINE) The metacharacter ^ matches at the beginning of the string and just after each newline character. The $ metacharacter matches at the end of the string and just before each newline character (by default ^ matches only at the beginning of ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.