0

I want to take number's from string

example:

1223_:2 
234423_:5

I only want to take this number's to _:

any idea for

 Pattern p = Pattern.compile(??????????)
1
  • I'm not sure whether I got you right: do you want only the first part of the number (e.g. 1223) or the whole number without "_:" (e.g. 12232)? Commented Dec 7, 2013 at 19:04

3 Answers 3

1
yourString.replaceAll("[^\\d]", "")
Sign up to request clarification or add additional context in comments.

Comments

0

What’s with the regex requirement?

String number = someOtherString.substring(0, someOtherString.indexOf('_:'));

2 Comments

this bring me the number after the ":" I just want the numbers before this ":" got resolution - take the index of "_:" and also use substring but with range substring(int, int) anyway thanks for take the good way :)
Yes, forgot the 0, part. Fixed. :)
0
String str = "1223_:2 234423_:5";
String[] numbers = str.trim().split("_:\\d+\\s*");

For a better answer we are gonna need more details. What exactly do you want to do?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.