question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unrecognized expression for regex that ends with `/=\s+[0-6]/`

See original GitHub issue

Current 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:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
davidmunechikacommented, Apr 18, 2022

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]/);

Screenshot 2022-04-18 at 11 10 10 AM
0reactions
cypress-bot[bot]commented, May 23, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found