1
4

3 に答える 3

2

How about

/[\u2019]/

It uses the actual character rather than the html entity. 2019 is hex for 821710

http://jsfiddle.net/eV2ek/

于 2012-10-19T23:02:43.430 に答える
1

As long as you properly tag encoding of your JavaScript (or its holding page if it is inline) either through charset attribute or Content-Type header, you can just use any character that doesn't have special meaning in regexp just by typing it there literally:

/’/
于 2012-10-19T23:43:39.933 に答える
0

Alternative of ’ or ’ in regex in most of environments is

\u2019

however in Perl and PCRE \u is not supported , but \x syntax instead

\x2019

as 2019 is hex of decimal 8217.

Regarding unicode with regex in Javascript read: Javascript + Unicode regexes

于 2012-10-19T22:59:18.733 に答える