0

content eg.
1. java.lang.String,
2. java.util.HashMap<Integer, Integer>,
3. java.util.ArrayList<Integer>,
4. java.util.HashMap<Integer, ArrayList<String>>,
5. java.util.HashMap<Integer, ArrayList<ArrayList<String>>>,

I need a regex for matching method parameters in Java.
I have tried with this one..
([a-zA-Z\. ]+,)|([a-zA-Z\. ]+<[a-zA-Z\., ]+(<[a-zA-Z\., ]+>)*>[ ]*,)

It is matching first 4 strings.
But it is not matching 5th one, since it is having nested <> combinations. (i.e. like <<<>>>)

How to make it to match 5th one also...
It should match all nested combinations of < & > to any depth...

Edited by sawant_nitesh: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Freaky_Chris
0

See this thread for a concept that may help you

http://forums.sun.com/thread.jspa?threadID=5172164
then see the site referenced there (reproduced here)
http://www.javaregex.com/

Only Perl and PHP have builtin support for this so the only resources I can point you to to help with the concept are pages concerning those languages, such as this one
http://perldoc.perl.org/perlfaq6.html
more specifically
http://perldoc.perl.org/perlfaq6.html#Can-I-use-Perl-regular-expressions-to-match-balanced-text?

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.