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

Improve thanks detection regex #1818

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

SilentRhetoric
Copy link

@SilentRhetoric SilentRhetoric commented Jan 11, 2025

This PR is intended to improve the success rate for the automatic detection of thanks by adjusting the regex to match more reliably around punctuation.

The current thanks detection regex...

(?i)( |\n|^)(thanks?\pP*|danks|ty|thx|\+rep|\+ ?\<\@[0-9]*\>)( |\n|$)

...misses several variants of "thanks" due to how the regex will only match if punctuation followed thanks but not other variants like ty and thx.

The improved thanks detection regex...

(?i)( |\n|^)?(thanks?|danks|ty|thx|\+rep|\+ ?\<\@[0-9]*\>)( |\pP|\n|$)

...will additionally catch variants like ty and thx when there is trailing punctuation.

Note: Matching on "danks" was not added by this PR; this variant was already in the regex when I found it. Although this has generated questions and skepticism with people whom I have asked to review the regex, I have left it in there.

The change has been tested using regex101.com's interactive tool for Golang-flavored regular expressions.

Before:
image

After:
image

@SilentRhetoric SilentRhetoric marked this pull request as ready for review January 11, 2025 15:04
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.

1 participant