矢量副本的正则表达式
Regular expression for vector copy
我想在我的代码库中搜索人们复制的地方,例如载体。
现在我在 Visual Studio 2010 和 grep 中用正则表达式 vector<.*>[ ]+
尝试了这个,但我似乎已经得到了非常错误的事情,因为它不起作用。
有人可以指出适用于其中之一的正确变体吗?
编辑:
我正在尝试匹配 vector<foo> blub = othervec;
之类的东西
你可能想要:
vector<[^>]*>\s+
其中 [^>]*
字符 class 将一直匹配,直到找到结束符 >
并且 \s+
将找到一个或多个空白字符。
为了不必在 grep 中转义 +
,您需要使用 -E
标志。或者,您可以将 +
转义为 \+
:
$ cat file
vector<foo> blub = othervec;
$ grep -E 'vector<[^>]*>\s+' file
vector<foo> blub = othervec;
$ grep 'vector<[^>]*>\s\+' file
vector<foo> blub = othervec;
怎么样
vector<.*?>.*?;
我想在我的代码库中搜索人们复制的地方,例如载体。
现在我在 Visual Studio 2010 和 grep 中用正则表达式 vector<.*>[ ]+
尝试了这个,但我似乎已经得到了非常错误的事情,因为它不起作用。
有人可以指出适用于其中之一的正确变体吗?
编辑:
我正在尝试匹配 vector<foo> blub = othervec;
你可能想要:
vector<[^>]*>\s+
其中 [^>]*
字符 class 将一直匹配,直到找到结束符 >
并且 \s+
将找到一个或多个空白字符。
为了不必在 grep 中转义 +
,您需要使用 -E
标志。或者,您可以将 +
转义为 \+
:
$ cat file
vector<foo> blub = othervec;
$ grep -E 'vector<[^>]*>\s+' file
vector<foo> blub = othervec;
$ grep 'vector<[^>]*>\s\+' file
vector<foo> blub = othervec;
怎么样
vector<.*?>.*?;