# | Likes | Tech tags | Title | Creator | Created date |
---|---|---|---|---|---|
1 | 0 |
2023-01-11 14:06
|
Matches using the standard re
module
import re
m = re.search(r'a=(\d+), b=(\d+)', 'Our coordinates are (a=123, b=5432), and we have some values too')
a = m.group(1) # acquires value '123'
b = m.group(2) # acquires value '5432'
functions | |
re.Match.group |
docs.python.org |
re.search |
docs.python.org |
classes | |
re.Match |
docs.python.org |
Construct a regex pattern with some groups. Find a segment of some string that matches said pattern and fetch the parts that match the groups specified by the pattern.