Reputation: 25463
Let's say I want to match one of the following characters: a
, b
, c
, or +
(in JavaScript). Do I need to escape the +
? Is it /[abc+]/
or /[abc\+]/
? Both work in my limited selection of test browsers. Which is (more) correct?
Upvotes: 7
Views: 3368
Reputation: 12683
Under character classes:
Any character except
^-]\
add that character to the possible matches for the character class.
In other words, you don't have to escape the +
.
Upvotes: 10