Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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 使用正则表达式查找两个子字符串之间的所有内容_Javascript_Regex - Fatal编程技术网

Javascript 使用正则表达式查找两个子字符串之间的所有内容

Javascript 使用正则表达式查找两个子字符串之间的所有内容,javascript,regex,Javascript,Regex,我试图找到两个子字符串之间的所有内容。例如:;jklasdfj;lkasdf=~~=alksdjf;lkajsd09823409283mvlb()*#@(*$(=^^^^=lkjdflkdjfkljdf 我想找到=~~=和之间的所有内容=^^= 我尝试了/(?您正在使用lookbehinds,Javascript正则表达式不支持它。尝试使用此表达式,并在括号之间恢复捕获组的值: > text = '=~~=hello=^^=' > regex = /=~~=(.*)=\^\^=/

我试图找到两个子字符串之间的所有内容。例如:
;jklasdfj;lkasdf=~~=alksdjf;lkajsd09823409283mvlb()*#@(*$(=^^^^=lkjdflkdjfkljdf

我想找到=~~=和之间的所有内容=^^=


我尝试了
/(?您正在使用lookbehinds,Javascript正则表达式不支持它。尝试使用此表达式,并在括号之间恢复捕获组的值:

> text  = '=~~=hello=^^='
> regex = /=~~=(.*)=\^\^=/
> text.match(regex)

[ '=~~=hello=^^=', 'hello', index: 0, input: '=~~=hello=^^=' ]

返回数组的元素
[1]
将是组的值。如果上面的示例(来自节点外壳)不清楚,请参阅关于MDN的更多信息。

您使用的是lookbehinds,Javascript正则表达式不支持它。请尝试使用此表达式,并在括号之间恢复捕获的组的值:

> text  = '=~~=hello=^^='
> regex = /=~~=(.*)=\^\^=/
> text.match(regex)

[ '=~~=hello=^^=', 'hello', index: 0, input: '=~~=hello=^^=' ]

返回数组的元素
[1]
将是组的值。如果上面的示例(来自节点外壳),请参阅关于MDN的更多信息不清楚。

在javascript中不存在lookback,因此将其更改为
=~~=
,并使用捕获组来提取所需内容。@casimirithippolyte我该怎么做???在javascript中不存在lookback,因此将其更改为
=~=
,并使用捕获组来提取所需内容。@casimirithippolyte我该怎么做?? ?