正则表达式查找具有特定数量参数的方法调用 [英] regex find method calls with specific number of arguments

查看:134
本文介绍了正则表达式查找具有特定数量参数的方法调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找某些方法的所有事件,但只有指定数量的参数(5):

I'm trying to find all occurencas of certain method, but only with specified number of arguments(5):

所以假设我有不同的方法同名和不同的args。

so let's say I have different methods with the same name and different set of args.

.method(asd,asd,asd,asd,asd,asd,asd)
.method(asd,asd,asd,asd,asd)
.method(asd,asd,asd)

我尝试过这样的事情: \.open \((?:。*?\,){4} [^,] *?\ )但它会返回所有带有5个或更多args的方法:

I've tried something like that: \.open\((?:.*?\,){4}[^,]*?\) but it gives back all methods with 5 and more args:

.method(asd,asd,asd,asd,asd,asd,asd)
.method(asd,asd,asd,asd,asd)

我只需要那些有4位的人。提前致谢!

I need only those with 4. Thanks in advance!

推荐答案

适合我:

egrep "\(([^,]*,){4}[^,]*\)"  method

评论建议:

egrep "open\s?\(([^,)]*,){4}[^,)]*\)"  methodfile

这篇关于正则表达式查找具有特定数量参数的方法调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆