sre_parse.parse_template
Prev: sre_parse.parse | Up: sre_parse | Next: sre_parse.PatternError
Rel: sre_parse.error, sre_parse.fix_flags, sre_parse.parse, sre_parse.PatternError
Ref: docs.python.org — sre_parse.parse_template
Tags: #public #python3 #stdlib #sre_parse
Import
import sre_parse
from sre_parse import parse_template
Signature & Overview
sre_parse.parse_template(source, pattern)
sre_parse.parse_template() function.
Usage
import re
# Use re.sub() for replacement templates directly
assert re.sub(r'(\w+)', r'[\1]', 'hi') == '[hi]'
Gotchas
- Deprecated internal shim.
REPL Inspect
from sre_parse import parse_template
help(parse_template)
Linked from
- tuts/python3/stdlib_module/sre_parse
- tuts/python3/stdlib_module/sre_parse/error
- tuts/python3/stdlib_module/sre_parse/fix_flags
- tuts/python3/stdlib_module/sre_parse/parse
- tuts/python3/stdlib_module/sre_parse/PatternError
- tuts/python3/stdlib_module/sre_parse/State
- tuts/python3/stdlib_module/sre_parse/SubPattern
- tuts/python3/stdlib_module/sre_parse/Tokenizer
Related notes
- tuts/python3/stdlib_module/sre_parse Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/error Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/fix_flags Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/parse Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/PatternError Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/State links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/SubPattern links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_parse/Tokenizer links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib