question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regex match vs search

See original GitHub issue

Some rules’ regular expressions are used with .search, some with .match, and the only source which one it is appears to be the gitlint source.

search: title-match-regex, body-match-regex match: author-valid-email, ignore-by-title, ignore-by-body, ignore-body-lines, ignore-by-author-name

I think it would be good to standardize on just one of these for all regex matching. I suggest going with .search, because .match is a Python oddity not present in any other language I know of. (It’s kind of ironic and unfortunate that the rules that have match in their name are the ones for which we do not invoke match, but search.)

Then again, standardizing on one would be a breaking change. If that’s not acceptable or will take some time, I think we should document which method is used with each rule. I’m available to help with that or making the search/match change (if we’re going with search 😉), let me know.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisrooverscommented, Feb 10, 2022

Good catch, I agree with the suggestion to standardize on search.

Wrt deprecation strategy:

  • I like the idea of a global feature flag to enable the new regex behavior (e.g. enable_regex_style_search=true, let me know if you have a better suggestion)
  • We don’t have any case today where gitlint logs warnings. Should be easy enough though. To state perhaps the obvious, this should only be logged for users who are actually using these rules and the warning should disappear when the enable_regex_style_search flag is set.
0reactions
jorisrooverscommented, Nov 17, 2022

Released as part of 0.18.0, closing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - What is the difference between re.search and re.match?
Python offers two different primitive operations based on regular expressions: match checks for a match only at the beginning of the string, while...
Read more >
Python | re.search() vs re.match() - GeeksforGeeks
There is a difference between the use of both functions. Both return the first match of a substring found in the string, but...
Read more >
What is the difference between re search and re match
Python offers two different primitive operations based on regular expressions: match checks for a match only at the beginning of the string, ...
Read more >
Python RegEx: re.match(), re.search(), re.findall() with Example
The match method checks for a match only at the beginning of the string while search checks for a match anywhere in the...
Read more >
What is the difference between re.match(), re.search() and re ...
The re.search() method is similar to re.match() but it doesn't limit us to find matches at the beginning of the string only.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found