HI I am new to regex, could anyone help me in finding the java code using regex:

My input string is : MyData 68309486 Bob

I want to fetch only the digits in sequence like 68309486.

PLz help me!!!

What you're looking for is called capturing group in java regex.
e.g. for this input: "world cup, football, asia, 2011"
- when you apply this regEx: "^world cup, football, ([^,]*), 2011$"
- then matcher.group(1) is set to "asia"
- when you apply "^world cup, ([^,]*), ([^,]*), 2011$"
- then matcher.group(1) is set to "football" and matcher.group(2) is set to "asia".

See javadoc/google for examples. You need to use Pattern.compile(), Pattern.mathcer() and matcher.group() methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.