| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
ParserElement --+
|
Token --+
|
Regex
Token for matching strings that match a given regular expression.
Defined with string specifying the regular expression in a form
recognized by the inbuilt Python re module. If the given regex contains
named groups (defined using (?P<name>...)), these will
be preserved as named parse results.
Example:
realnum = Regex(r"[+-]?\d+\.\d*")
date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)')
# ref: http://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression
roman = Regex(r"M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})")
make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
print(make_html.transformString("h1:main title:"))
# prints "<h1>main title</h1>"
| Nested Classes | |
|
compiledREtype Compiled regular expression objects |
|
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
| Static Methods | |
|
Inherited from |
| Class Variables | |
__slotnames__ =
|
|
|
Inherited from |
|
| Properties | |
|
Inherited from |
| Method Details |
The parameters
|
|
str(x)
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Oct 31 00:55:29 2018 | http://epydoc.sourceforge.net |