我用梵文字的HTML代码
<html>
<head>
<title>TODO</title>
<meta charset="UTF-8">
</head>
<body>
?????? ???????????
</body>
<script src="jquery-1.11.0.min.js"></script>
<script src="xregexp_20.js"></script>
<script src="addons/unicode/unicode-base.js"></script>
<script src="addons/unicode/unicode-scripts.js"></script>
<script src="my.js"></script>
</html>
Run Code Online (Sandbox Code Playgroud)
我的javascript代码
var html = document.getElementsByTagName("html")[0];
var fullpage_content = html.innerHTML;
var regex = RegExp("??????", "g");
var count = fullpage_content.match(regex);
console.log("count in page : " + count+ ", " + count.length);
//use of word boundry ,not supported by devanagari characters
regex = RegExp("\\b??????\\b", "g");
count = fullpage_content.match(regex);
console.log("count in page : " + count);
regex = XRegExp("??????");
var match = …Run Code Online (Sandbox Code Playgroud)