Regularly match Chinese characters

 Has the following characters:

<li><a href="/song?id=185613">惊叹号</a></li><li><a href="/song?id=185614">迷魂曲</a></li>  
How to write regular expressions to match "Vertigo"?
 
answer:
            reg1 = /id=185614">([u4e00-\u9fa5]{3})<\/a>/g;

            var str = '<li><a href="/song?id=185613">惊叹号</a></li><li><a href="/song?id=185614">迷魂曲</a></li>';

            var matches = reg1.exec(str);

            console.log(matches[1]);

[u4e00-\u9fa5] can match Chinese characters. {3} means match 3 characters.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324623338&siteId=291194637