0

Hi,

i have a string that i want to match to a regular expression. The string is
methodName(paraT1 para1, paraT2.name2 para2, paraT3.name3 para3)
Inside the () there can be multiple of "aaa.bbb ccc" and "ddd eee" patterns

The regular expression i wrote was :

(\w)(\s)((((\w.\w)\s(\w))|((\w)\s(\w)))(\s\,\s(((\w.\w)\s(\w))|((\w)\s(\w))))*)

and the I get the first and the last (parameterType para) pattern but not the ones inbetween. How do i get the middle expression.

appreciate a reply
thanks in advance

3
Contributors
6
Replies
20
Views
3 Years
Discussion Span
Last Post by srider1969
0

how do i repeat the regular expression section
(\s\,\s(((\w.\w)\s(\w))|((\w)\s(\w*))))

0

Your first question leads to named groups. To capture something specific it is easier to give it a name.

\w+\((?<first>[\w\s\.])+,(?<second>[\w\s\.])+,(?<third>[\w\s\.])+\)

Your second question could be reduced to

,?[\w\s\.]+

.

What language are you using to run your regex?

Edited by srider1969: Misread

0

Or

(?<=\()((?:,?)[\w\s\.]+){3}(?=\))

to target all items between the parentheses.

Edited by srider1969: improvement

0

1) Old post
2) This is Java, so RegEx is being used in Java
3) I am not sure but in Java, iirc, your RegEx string needs to specify leading and ending part with matches() method. Not sure about RegEx class.

0

A quick check against the Java engine in RegexBuddy shows my first re named grouping is different somehow.

Favorite language/favorite tool!

Edited by srider1969: update

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.