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

Use real regexes for checking #111

Open
JJ opened this issue Aug 10, 2023 · 2 comments
Open

Use real regexes for checking #111

JJ opened this issue Aug 10, 2023 · 2 comments
Labels
enhancement New feature or request hacktoberfest-accepted Accepted for hacktoberfest 2023 help wanted Extra attention is needed

Comments

@JJ
Copy link
Owner

JJ commented Aug 10, 2023

Right now it's tricky, since strings are rexified; it's probably better to add new features for checking real regexes. You can code alternatives into regexes, so using several ones might not be it.

@JJ JJ added the enhancement New feature or request label Aug 10, 2023
@JJ JJ added this to the v14 milestone Aug 10, 2023
@JJ JJ added help wanted Extra attention is needed hacktoberfest-accepted Accepted for hacktoberfest 2023 labels Oct 1, 2023
@JJ JJ modified the milestones: v14, v15 Feb 16, 2024
@JJ JJ changed the title Use multiple regexes for checking Use real regexes for checking Feb 16, 2024
@JJ JJ removed this from the v15 milestone Feb 16, 2024
@rshih32
Copy link

rshih32 commented Feb 22, 2024

Thanks for making this github action!

Just wondering if you rexify by escaping: 6f56b9f

Could you just "reverse" the meaning of the escape?

so \s\* would be the original regex \s*

Assuming that would be okay, you could just process the expression twice.

["(", ")", "[", "]", "?", "+", "*"].forEach((s) => {
  expression = expression.replace(s, `\\${s}`);
});
["\\\\(", "\\\\)", "\\\\[", "\\\\]", "\\\\?", "\\\\+", "\\\\*"].forEach((s) => {
  expression = expression.replace(s, `${s.slice(-1)}`);
});
return new RegExp(expression);

@JJ
Copy link
Owner Author

JJ commented Feb 23, 2024

Thanks for the suggestion. I drew myself into a corner here. I think that the solution will rather be to use a different parameter for regexes, so that it keeps compatibility, maybe together with a deprecation cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest-accepted Accepted for hacktoberfest 2023 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants