Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用CasperJS检查unicode范围_Javascript_Unicode_Casperjs - Fatal编程技术网

Javascript 使用CasperJS检查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'); })

我正在尝试使用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');
    }).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
就完成了看起来的任务