The regex module

(Obsolete) This is the old (pre-1.5) regular expression machinery. New code should use re where possible.

Note that regex is often faster than the re module used in Python 1.5.2, but slower than the new version used in 1.6 and later.

Example: Using the regex module
# File:

import regex

text = "Man's crisis of identity in the latter half of the 20th century"

p = regex.compile("latter") # literal
print p.match(text)
print, repr(

p = regex.compile("[0-9]+") # number
print, repr(

p = regex.compile("\<\w\w\>") # two-letter word
print, repr(

p = regex.compile("\w+$") # word at the end
print, repr(

$ python
32 'latter'
51 '20'
13 'of'
56 'century'

A Django site. rendered by a django application. hosted by webfaction.