Python: Search for regex pattern in string
30 October 2022 (Updated 20 November 2022)
import re
# re.match only search for match at the beginning
# so this won't return a match
re.match("c", "abcdef")
# re.search will search for match anywhere in the
# string so this will match
re.search("c", "abcdef")
<re.Match object; span=(2, 3), match='c'>
Sources
Tagged:
Python