Skip to content

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

Open
@a2937

Description

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. 

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions