Reputation: 11
I want to create a regular expression using Java for function declaration for the following pattern which should give me function name "setFeatureSetting" and parameter dictObj
for the following input :
Function setFeatureSetting(dictObj)
how can i write Regular Expression for function declaration
I have written Regex for content between round bracket (\(([^)]+)\))
and this also find Function (.*)\(.*|[\r\n]\)\n
but how can i get setFeatureSetting
?
Upvotes: 0
Views: 205
Reputation: 52185
I think that for a regex, you have provided too few examples, usually, what you are after, what you are getting and what do you not want to get are of great help.
That being said, using your single example as a guide, something like this should work:
\\s+(.+?\\((.+?)\\))
It should put the function name and the paramater you are trying to match into 2 groups, which you can then extract at a later stage.
It will match setAbc(obj)
but not setAbs()
and set()
.
Upvotes: 1