Python Regular Expression to Java Regular Expression

Can anybody convert the following Python RegEx to Java?

re.findall(r"(\w+\([^)]*\))", string)
dshrenikAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
what is this regular expression doing? i can suggest the equivalent one for java
dshrenikAuthor Commented:
find all occurrences of the following in an input string (in the order in which they occur)
a string of alphanumerics, followed by an opening parentheses, followed by some string (possibly quoted), followed by a closing parentheses

For example if the input is " a1('ds f')   x3('dsf f')    ab('sdf')   xyz('dsf'), then the output must be collected in an array in this order:
a1('ds f')
x3('dsf f')
ab('sdf')
xyz('dsf')
Gurvinder Pal SinghCommented:
check this sample program
package com.pocs.one;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Regex1
{
	public static void main(String[] args)
	{
		String regex = "\\w+\\('[\\w+\\s*]+'\\)";
		
		String input = "a1('ds f')   x3('dsf f')    ab('sdf')   xyz('dsf')";

		Pattern pattern_css = Pattern.compile(regex);
		Matcher match_css = pattern_css.matcher(input);
		
		while (match_css.find())
		{
			System.out.println(match_css.group());
		}
	}
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dshrenikAuthor Commented:
Works great. Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.