Closed jrafaaael closed 1 month ago
match method try to match only from the start of the string search method try to match from anywhere on the string
match
search
in my specific use case, word boundary (\b) doesn't work with match if the sub-string I looking for is in the middle of the string
\b
>>> import re >>> r = re.compile(rf"\babc\b") >>> r.match("xxx abc yyy") # doesn't work >>> r.search("xxx abc yyy") # work <re.Match object; span=(4, 7), match='abc'>
a workaround can be found here (r = re.compile(fr"^.*\babc\b.*$")) but word boundary alone should work too
r = re.compile(fr"^.*\babc\b.*$")
# fixes #330
match
method try to match only from the start of the stringsearch
method try to match from anywhere on the stringin my specific use case, word boundary (
\b
) doesn't work withmatch
if the sub-string I looking for is in the middle of the stringa workaround can be found here (
r = re.compile(fr"^.*\babc\b.*$")
) but word boundary alone should work too# fixes #330