tags: python regex title: Python Regex 001 The [official docs](https://docs.python.org/3/library/re.html). # Flags ```py r.search(subject,re.I| re.search(pattern,subject,re.I) ``` # Match Objects ```py m = re.search(pattern,subject) m.group(0) # whole match m.group(1) # capture groups m.start(), m.end() # location of match in subject # so left = subject[:m.start()] mid = subject[m.start():m.end()] right = subject[m.end():] ``` # Findall See [the docs](https://docs.python.org/3/library/re.html) ```py re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest') ['foot', 'fell', 'fastest'] re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10') [('width', '20'), ('height', '10')] ```