Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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 如何在不包含${variable}的字符串周围编写正则表达式查找`(严重重音)_Javascript_Regex - Fatal编程技术网

Javascript 如何在不包含${variable}的字符串周围编写正则表达式查找`(严重重音)

Javascript 如何在不包含${variable}的字符串周围编写正则表达式查找`(严重重音),javascript,regex,Javascript,Regex,我需要一个正则表达式来查找字符串周围的严重重音,但如果该字符串包含${someVar},则不需要 consttwomatch=`teststring`; const noMatches=`test${variabel}`; 用普通的撇号代替严肃的口音会很好。试试这个 (?<!.*\${.*)(\b\w+\b)(?!.*}.*) (? 说明: (?<!.*\${.*) : not precided by '${' in any place (?!.*}.*) : not follo

我需要一个正则表达式来查找字符串周围的严重重音,但如果该字符串包含
${someVar}
,则不需要

consttwomatch=`teststring`;
const noMatches=`test${variabel}`;
用普通的撇号代替严肃的口音会很好。

试试这个

(?<!.*\${.*)(\b\w+\b)(?!.*}.*)
(?
说明:

(?<!.*\${.*) : not precided by '${' in any place
(?!.*}.*) : not followed by '}' in any place
\b : word boundry
\w+ : 1 or more character [a-zA-z0-9_]
(?

无论是
twoMatch
还是
noMatches
都不包含任何内容。我没有在字符串值中搜索,我想使用IDE搜索来查找周围的严重重音,从而将其定义为字符串值。因此,您已将JS文件作为文本打开并正在搜索?--
'==`true
我正在打开JS fVisual Studio代码中的ile(在本例中实际上是TS)。并使用搜索来查找严重的口音。这是否回答了您的问题?看起来非常有希望!我在IDE(Visual Studio代码)中尝试了它,但它抱怨它是无效的“不完整量词”.但从第二个角度看,它与字符串匹配,而不是与格雷斯口音匹配。我不相信这在正则表达式中是可能的。可能需要一些代码。比如linter规则。在计算中,我认为`的术语是“back tick”或“backquote”