Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.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
使用RegExp搜索双引号和单引号的Javascript字符串_Javascript_Reactjs_Regex_Regexp Substr - Fatal编程技术网

使用RegExp搜索双引号和单引号的Javascript字符串

使用RegExp搜索双引号和单引号的Javascript字符串,javascript,reactjs,regex,regexp-substr,Javascript,Reactjs,Regex,Regexp Substr,我使用以下代码来搜索字符串中的子字符串 mystring.search(new RegExp(substring, 'i')) 我使用newregexp的原因是,我希望搜索不区分大小写。但是,当有一个字符串 var mystring='10“stick'; 我想搜索10”,上面的代码不会返回任何结果。这显然是因为新的RegExp和双引号。是否有任何特定的标志需要在new RegExp中传递?我在谷歌上搜索了很多,但找不到任何解决方案。我遗漏了什么?返回比赛位置,可能你对此感到困惑 那么,试试这

我使用以下代码来搜索字符串中的子字符串

mystring.search(new RegExp(substring, 'i'))
我使用
newregexp
的原因是,我希望搜索不区分大小写。但是,当有一个字符串

var mystring='10“stick';

我想搜索
10”
,上面的代码不会返回任何结果。这显然是因为
新的RegExp
和双引号。是否有任何特定的标志需要在
new RegExp
中传递?我在谷歌上搜索了很多,但找不到任何解决方案。我遗漏了什么?

返回比赛位置,可能你对此感到困惑
那么,试试这个

constmystring='10“stick';
log(myString.match(新的RegExp('10','i'))[0])
log(myString.match(新的RegExp('ick','i'))[0])
console.log(myString.match(newregexp('asd','i'))//不匹配