[英]Is there any way to exclude the last occurence of a character from a regex group with grep
我想写一个与以下行匹配的正则表达式:
int func ( int argument, char* str)
for( int i = 0; i < 25; i++)
if( true )
但不是那些:
int func (int argument char* str)
for(int i = 0; i i < 25; i++)
if(true)
在litteral中,我想匹配在左括号后面有任何空格的行或在右括号之前的任何空格。
我开始编写以下正则表达式:
grep -E '[^\(]\( [^ ] \)'
但它不起作用,因为括号之间可能有有效的空格。
我的问题是:有没有办法从正则表达式组中排除角色的最后一次出现?
在litteral中,我想匹配在左括号后面有任何空格的行或在右括号之前的任何空格。
您可以使用此grep
进行更改:
grep '([[:blank:]]\|[[:blank:]])' file
grep
正则表达式模式(BRE)中,不需要转义(
和)
[[:blank:]]
匹配空格或制表符 |
在BRE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.