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

Regex shouldn't work #204

Open
gwelch-contegix opened this issue Dec 13, 2022 · 2 comments
Open

Regex shouldn't work #204

gwelch-contegix opened this issue Dec 13, 2022 · 2 comments
Labels

Comments

@gwelch-contegix
Copy link

Can I get an explanation as to why this regex works (?P<project_id>\w+)(-)(?P<jira_id>\d+)?
It's suggested to use https://regex101.com to test but testing with it matches on all sorts of things that I don't want it to, mainly destroying links, https://regex101.com/r/XPUAgu/4
Now on Mattermost it works how I want it to, but how is https://regex101.com or any other website/knowledge I have access to supposed to help me write a regex for this plugin?
If I write a regex that does work on https://regex101.com (?P<pre>\s|^)(?P<number>KEY-\d{1,4}) https://regex101.com/r/axJv7b/1 it then fails to match properly in Mattermost and also has issues displaying the regex.
Screenshot 2022-12-13 at 10 45 45

@DHaussermann
Copy link

@m1lt0n or @hanzei would you know who can help with this question? I don't know if there is a more accurate tool to use a a reference for how the plugin evaluates the expressions.

@hanzei hanzei added the Triage label May 21, 2023
@robonaj
Copy link

robonaj commented Oct 13, 2023

It is not obvious from the documentation, but when all options DisableNonWordPrefix, DisableNonWordSuffix, and WordMatch are disabled (which is the case if they are not shown in the /autolink list output), autolink modifies the pattern as seen in the Compile function.
Your regex becomes (?P<MattermostNonWordPrefix>(^|\s))(?P<project_id>\w+)(-)(?P<jira_id>\d+)(?P<MattermostNonWordSuffix>$|[\s\.\!\?\,\)]) - see https://regex101.com/r/fC8DaU/1 with your example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants