Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想找到所有以 @ 开头且不以相等 (=) 结尾的单词
"@parameter" ---> result = "@parameter" "@parameter = @first" ---> result = "@first" "@parameter = @first, @parameter = @second" ---> result = "@first" and "@second"
提前致谢
使用 regex @\w+\b(?!\s*=),这意味着寻找@后跟一些不跟的单词=(带有可选的前导空格字符)
@\w+\b(?!\s*=)
@
=
使用贪婪量词直到行尾并回溯搜索可选的=,其中:
^.*=?\s*(@\w+)\s*$