Unrecognized expression for regex that ends with `/=\s+[0-6]/`
See original GitHub issueCurrent behavior
I have a cy.contains()
call with the following:
cy.contains(/[56]\s+-\s+[0-6]\s+=\s+[0-6]/);
And it fails with:
Error: Syntax error, unrecognized expression: :cy-contains('/[56]\s+-\s+[0-6]\s+='\s+[0-6']/'), [type='submit'][value~='/[56]\s+-\s+[0-6]\s+='\s+[0-6']/']
It looks like there are extra single quotes? I’m not sure. The minimal code that throws the same error is:
cy.contains(/=\s+[0-6]/);
Desired behavior
Should not throw Error “Syntax error, unrecognized expression”.
Test code to reproduce
https://github.com/asartalo/cypress-test-cy-contains-fail
Cypress Version
9.5.4
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Unrecognized expression '$regex' - mongodb - Stack Overflow
$regex is a query operator, you are trying to use it within an $expr which uses the "aggregation" language as oppose to the...
Read more >cy.contains will throw unrecognized expression error if it tries ...
contains will throw unrecognized expression error if it tries to match against regex containing single quotation mark #8626.
Read more >Regular expression - Wikipedia
A regular expression is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms...
Read more >Re: s6-log problem with +regex - skarnet.org
The regular expression preceded by a + unintentionally matches ... >s6-log: fatal: unrecognized directive: - Now that is interesting.
Read more >Common Bash Commands - CIS2
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for opening an issue! I was able to reproduce this issue and it does appear to be a bug in how we are handling RegEx. It also seemed to fail with
cy.contains(/=[0-6]/);
Released in
9.7.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v9.7.0, please open a new issue.