如何创建正则表达式来查找没有大括号的C代码块?
我需要一个正则表达式来查找C语言中的代码块,出于代码安全原因,这些代码块应该始终与大括号(if、for、do、while…)一起使用 例如: 我需要匹配:如何创建正则表达式来查找没有大括号的C代码块?,c,regex,C,Regex,我需要一个正则表达式来查找C语言中的代码块,出于代码安全原因,这些代码块应该始终与大括号(if、for、do、while…)一起使用 例如: 我需要匹配: if (a) anything 但不是: if (a) { anything } Tried to create it using a negative lookahead pattern but did not work: \tif\(*.*\n\t*(?!\{).* This will be used on Visua
if (a)
anything
但不是:
if (a)
{
anything
}
Tried to create it using a negative lookahead pattern but did not work: \tif\(*.*\n\t*(?!\{).*
This will be used on Visual Studio Code.
Any suggestions?
正则表达式无法做到这一点。可能
\bif\s*\([^()]*\)\n(?!\t*\{)。*
()?我知道你已经看到了这个建议,你有时间检查它吗?在VSCode上试过了,但不起作用。它将if块与{匹配。