Take the 2-minute tour ×

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?

share|improve this question
Escaping won't work in this instance. Try ASCII. –  SomeKittens Jul 20 '12 at 20:58
The ASCI code for one of them is &#180;. Can you show me how to do this? –  user1436111 Jul 20 '12 at 20:59
This could all be lost in cut'n paste. Post the full JS test you tried that failed. 'â€™â€˜ looks like byte code. –  sln Jul 20 '12 at 21:04
Have you saved your script using ASCII encoding or UTF-8 encoding? Download a program like Notepad++ and change the encoding, if you are unsure. Make sure all of your files use UTF-8 encoding then add <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> to the head of your HTML files. –  Oliver Moran Jul 20 '12 at 21:05

2 Answers 2

up vote 1 down vote accepted



This matches either one of '’‘.


In JavaScript regexes, \u1234 matches the Unicode codepoint 1234. To find out the correct codes for this special case, I copied the characters into EditPadPro and had it convert them into Unicode codepoints.

share|improve this answer
Some explanation would by nice. Those "try this"-answers really only give the fish, but don't show how to fish. –  phresnel Jul 20 '12 at 21:20
You are my hero. –  user1436111 Jul 20 '12 at 21:22

Use unicode or octal codes:

/\u0022/ // matches "
/\042/ // matches "
share|improve this answer
Octal codes have been deprecated in the latest version of JS. –  zzzzBov Jul 20 '12 at 21:09
Good to know. You know why? –  elclanrs Jul 20 '12 at 21:10

Your Answer


