Matcher and regex

I have this string newstr that I want to parse:

[( ?A = <> ), ( ?A = <> )]

With the code shown below I get this as result:

[#Hello>, #World>]

What should I change to get:

Hello, World


List<String> strlist = new ArrayList<String>() ;

                  Pattern p = Pattern.compile("#([^>]+)>");
                   Matcher m = p.matcher(newstr);

                   while (m.find()) {

   String[] strto2 = strto.toArray(new String[20]) ;


If Java can do look behind assertions, maybe this:


P.s. – I didn’t look at the other question (should have, but ..)

Leave a Reply

Your email address will not be published. Required fields are marked *