Musical Shore
Musical Shore

Reputation: 1381

JavaScript regex matching character it shouldn't match

I have the following regex that checks for characters not in the character class:

[^\w+\-:\.\(\)\"\*\?\&\|\!\{\}\[\]\^~\\@\#\/\$\%\'\= ]

I'm expecting that it doesn't match the dash '-' on the following string, however it is:

SEPCO−SEPA50PT−S−TFA−ALC18−PZ4

Upvotes: 0

Views: 105

Answers (1)

James Thorpe
James Thorpe

Reputation: 32202

The in this:

SEPCO−SEPA50PT−S−TFA−ALC18−PZ4

is not the same character as the - in your regex. It is in fact the Unicode MINUS-SIGN rather than the Unicode HYPHEN-MINUS.

Here are the two next to each other showing they're different:

-

Upvotes: 4

Related Questions