Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
import re text = "cat concatenate" # \b matches whole words print(re.findall(r"\bcat\b", text)) # ["cat"] # ^ and $ with re.MULTILINE lines = "first second third" starts = re.findall(r"^\w+", lines, re.M) print(starts) # ["first", "second", "third"]
Result
Open