正则表达式查找具有特定数量参数的方法调用

编程入门 行业动态 更新时间:2024-10-27 01:34:09
本文介绍了正则表达式查找具有特定数量参数的方法调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试查找某些方法的所有事件,但只有指定数量的参数(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

更多推荐

正则表达式查找具有特定数量参数的方法调用

本文发布于:2023-10-23 19:42:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数量   参数   方法   正则表达式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!