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.

Unexpected regex behavior, dash in character class

See original GitHub issue
var token = /^[a-zA-Z0-9_!#$%&'*+.^`|~-]+$/;
console.log( token.test('Content-Type') );

The above prints false while it should be true

tested with duktape v 1.4 & nodejs v6.9.5 and latest chrome / firefox all give true

it seems that removing end regex match will fix this

var token = /^[a-zA-Z0-9_!#$%&'*+.^`|~-]+/;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
svaaralacommented, Jun 16, 2017

Ok, #1570 has a bug test case and a fix. I’ll merge it once the tests pass.

0reactions
svaaralacommented, Jun 17, 2017

Hehe, thanks 😃 This one was luckily a small bug probably introduced when reworking some lexer stuff for 2.0 release.

Thanks for reporting it, now it’s covered by testcases too 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you escape a hyphen as character range in a POSIX ...
1. hyphen located at the middle of character class would act as a range operator. · 3. @AvinashRaj I don't think this is...
Read more >
unexpected behavior in RegularExpressionProtection...
Hi Apigee Experts I am trying to put regular expression on request json ... You have a negative lookahead assertion with a character...
Read more >
Character classes - JavaScript - MDN Web Docs - Mozilla
A character class. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen, but if...
Read more >
Character Ranges & Class Negation in Regular Expressions
Now is an appropriate time to review the fourth character that must be escaped in a character class: The 'dash', or 'hyphen' character....
Read more >
Insufficient information on hyphen behaviour inside character ...
the dash ( - ) is mostly a normal character in Regex except when used in character classes. If the dash is not...
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