Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding special char to regular expression?

I have a regular expression that matches three kinds of apostrophes, '’‘. I directly pasted the last two from Microsoft word into the regex. However when I test it, my regular expression fails and when I inspect my javascript validation script in firefox, I see '’‘\ instead of '’‘. Do I need to escape them or use the ASCII format?

like image 879
user1436111 Avatar asked Oct 08 '22 04:10

user1436111


1 Answers

Use unicode or octal codes:

/\u0022/ // matches "
/\042/ // matches "
like image 97
elclanrs Avatar answered Oct 13 '22 10:10

elclanrs