Javascript 使用CasperJS检查unicode范围
我正在尝试使用unicode范围Javascript 使用CasperJS检查unicode范围,javascript,unicode,casperjs,Javascript,Unicode,Casperjs,我正在尝试使用unicode范围[\u4e00-\u9fa5]检查汉字,但我的casperjs脚本失败 这就是我想做的 casper.test.begin('unicode test', 1, function(test) { casper.start('http://us.weibo.com/gb', function(){ test.assertMatch(/[\u4e00-\u9fa5]/, 'checking for ch characters'); })
[\u4e00-\u9fa5]
检查汉字,但我的casperjs脚本失败
这就是我想做的
casper.test.begin('unicode test', 1, function(test) {
casper.start('http://us.weibo.com/gb', function(){
test.assertMatch(/[\u4e00-\u9fa5]/, 'checking for ch characters');
}).run(function() {
test.done();
});
});
这是测试结果的一部分
1失败测试的详细信息:
In check-for-ch-char.js:628
unicode test
uncaughtError: Invalid regexp.
如果我从起始url复制/粘贴任何字符,我可以看到unicode范围使用regexr工作。我想我已经找到了答案。我真的不知道为什么,因为我对casperjs是相当陌生的,所以如果有人能详细说明这一点,那将是有用的 我像这样编辑了我的测试
test.assertMatch(this.page.content,/[\u4e00-\u9fa5]/,“检查ch字符”)
这样做的目的是查找与unicode范围相匹配的内容。以前,我有test.assertMatch(/[\u4e00-\u9fa5]/,“检查ch字符”)
和范围没有查看任何内容,但我认为它会自动查看此内容的起始url
因此,包括this.page.content
就完成了看起来的任务