繁体   English   中英

用于检测未用双引号括起来的单词和字符串的正则表达式

[英]A regex to detect a word and a string that is not enclosed in double quotes

我试图为示例代码编写一个正则表达式,以在 grep 搜索中使用。

我的要求是获得仅与以下匹配的字符串输出

执行(这里的任何词)

例如。

execute(any)
execute(math)

结果不应该输出

execute("any")
execute("math")

我已经尝试了以下方法,但问题在于它输出了所有内容并且没有给我所需的解决方案。

grep -E '^execute\(*([^)]+)*\)'

我希望我的输出是 execute(math) 或 execute(s) 而不是

执行(“数学”)或执行(“s”)

根据您有限的样本数据,这应该有效:

^execute\([a-zA-Z]+\)$

https://regex101.com/r/S4owrs/2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM