Issue
I want to use the Eclipse search to find all method calls for a method which takes a variable argument count, like this: public void myMethod(String s, Object o, String... categories)
and get all which have specific counts of the optional parameter at the end.
So for example i would like to find all occurrences of myMethod("test", niceObject)
when i want those without any optional parameters. I know atleast this part can be done via regex, but this will stop working as soon as someone has split it up into multiple lines (or my regex-fu isn't strong enough :) ).
Any suggestions appreciated, be it using the eclipse built-in search functionality or a good regex which can deal with multiline method calls-
Solution
(?s)foo\(([^,]+,){2}[^,]+\);
matches calls to a method foo
with 3 parameters.
Here are the details:
(?s)
is used for matching multiple lines[^,]+
matches everything but,
([^,]+,){2}
matches a list of 2 arguments; replace 2 with the number of arguments you want - 1[^,]+\);
matches the last argument, followed here by);
Answered By - Emmanuel Chebbi