dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.63k stars 347 forks source link

refactor: use `search` instead of `match` to look for attr that match #331

Closed jrafaaael closed 1 month ago

jrafaaael commented 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

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

>>> 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

# fixes #330