Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEx for finding copy constructors

I was trying to find all occurences of my c# copy constructor-like constructors with the search window in visual studio using regex.

For example, I would like to find the following:

MyClass(MyClass other)

I used the following regex, but it did not give any results (it should):

(?<cn>\w)\(?<cn> \w\)

What do I do wrong please?

Many thanks.

like image 460
Gyula Kósa Avatar asked Sep 14 '26 06:09

Gyula Kósa


1 Answers

Based on your answers, I could successfully build the right RegEx for Visual Studio:

(?<cpy>\b\w+\b)\s*\(\s*\k<cpy>\s+\w+\s*\)
like image 74
Gyula Kósa Avatar answered Sep 16 '26 22:09

Gyula Kósa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!