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

[Feature Request] - Add a fulll regex match method on assert #1643

Open
a2937 opened this issue Oct 3, 2024 · 0 comments · May be fixed by #1644
Open

[Feature Request] - Add a fulll regex match method on assert #1643

a2937 opened this issue Oct 3, 2024 · 0 comments · May be fixed by #1644

Comments

@a2937
Copy link

a2937 commented Oct 3, 2024

Unfortunately the .match follows the standard Javascript Regex engine behavior of string.test returning true if there is a partial match. This behavior works great except for a few examples.

Example)

const freeRegex = /fr[e3]|[e3]|[e3] money/i; 

This regular expression will register as match for the phrase fr33 mon3y despite that logic tells us there shouldn't be. I want a method that runs String.match from the input ( fr33 mon3y) on freeRegex. From there I want to compare if the the first match (index 0 ) from the return value) is equal to original input.

It would be the equivalent of running something to the following as a one line assertion.

const freeRegex =  /fr[e3][e3] mon[e3]y/ig;
const matches = "fr33 mon3y".match(freeRegex); 
chai.assert.equal(matches[0],"fr33 mon3y") 
``

Thank you. 
@a2937 a2937 linked a pull request Oct 4, 2024 that will close this issue
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 a pull request may close this issue.

1 participant