正则表达式获取方法参数名称 [英] Regex to get method parameter name

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

问题描述

需要正则表达式来只替换参数名.通过程序,我能够获取参数名称,但是在使用常规表达式替换它时,当参数类和参数名称相同时,它会失败.像下面的方法:
getCustomerCyclesListInfo(CustomerCyclesListInfo CustomerCyclesListInfo, CustomerCyclesListInfo CustomerCyclesListInfo)

Need regular expression to replace only parameter name. By program i am able to fetch the parameter name but while replacing it using regular exression , its failing when we have both parameter class and parameter name as same. like below method:
getCustomerCyclesListInfo( CustomerCyclesListInfo CustomerCyclesListInfo, CustomerCyclesListInfo CustomerCyclesListInfo)

我尝试使用下面的正则表达式,但它匹配上面的所有四个:(?

i tried with below regex but its matching all four in above : (?<!\()\b(CustomerCyclesListInfo)\b

我希望在捕获时不应考虑以 ( (左括号) 空格或 ,(coma) 空格开头的单词.

i want that word starting with ( (opening parenthesis) space or ,(coma) space should not be considered while capturing.

推荐答案

试试这个:

\bCustomerCyclesListInfo(?= *[,)])

查看现场演示.

这篇关于正则表达式获取方法参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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