Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

jrafaaael
Copy link
Contributor

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

@dtmilano dtmilano merged commit 2971f5f into dtmilano:master Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__findViewWithAttributeInTreeThatMatches should use search instead of match
2 participants