<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script>
var result = (new RegExp("/^[\u4e00-\u9fa5]$/")).test("所");
console.log(result);
</script>
</head>
<body>
</body>
</html>
为什么输出的是false?文件用vim :set fileencoding 确认是用UTF-8编码的
var result = (new RegExp("^[\\u4e00-\\u9fa5]$")).test("所");
console.log(result);