Files
ui-cviko1/notebook/cviko2_regex.ipynb
2025-02-26 10:17:11 +01:00

2.3 KiB

In [3]:
import re

matches = re.match("I feel (.*)", "I feel happy today")
In [2]:
print(matches)
<re.Match object; span=(0, 18), match='I feel happy today'>
In [3]:
matches.groups()
Out[3]:
('happy today',)
In [4]:
"this is my first value = {}".format(3)
Out[4]:
'this is my first value = 3'
In [1]:
"{} first and {} second".format("f1", "f2")
Out[1]:
'f1 first and f2 second'
In [4]:
"Why do you feel {}?".format(matches.groups())
Out[4]:
"Why do you feel ('happy today',)?"