Regex to get method parameter name
Clash Royale CLAN TAG#URR8PPP
Regex to get method parameter name
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)
getCustomerCyclesListInfo( CustomerCyclesListInfo CustomerCyclesListInfo, CustomerCyclesListInfo CustomerCyclesListInfo)
i tried with below regex but its matching all four in above :(?<!()b(CustomerCyclesListInfo)b
(?<!()b(CustomerCyclesListInfo)b
i want that word starting with ( (opening parenthesis) space or ,(coma) space should not be considered while capturing.
1 Answer
1
Try this:
bCustomerCyclesListInfo(?= *[,)])
See live demo.
( CustomerCyclesListInfo CustomerCyclesListInfo , CustomerCyclesListInfo CustomerCyclesListInfo )
i tried with
(bCustomerCyclesListInfo)((?=(s*,))|(?=(s*))))
can it be refined more ?– Sandeep Chauhan
Aug 8 at 18:00
(bCustomerCyclesListInfo)((?=(s*,))|(?=(s*))))
@SandeepChauhan done. see updated regex and demo link
– Bohemian♦
Aug 8 at 18:00
thanks for help , its simple to understand and what i want :)
– Sandeep Chauhan
Aug 8 at 18:03
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
can u please also update the above regex if i have space after the parameter name also , as its not matching
( CustomerCyclesListInfo CustomerCyclesListInfo , CustomerCyclesListInfo CustomerCyclesListInfo )
if we have space between parameter name and , or )– Sandeep Chauhan
Aug 8 at 17:53