java - How to extract numbers from a string using regex? -
this question has answer here:
- how extract numbers string 2 answers
string = "sin(23)+cos(4)+2!+3!+44!"; a.replaceall("(\d+!)",""); current output = sin(23),+,cos(4),+,+,+
i want result 2!,3!,44!
please help
string = "sin(23)+cos(4)+2!+3!+44!"; pattern number = pattern.compile("\\d+!"); matcher matcher = number.matcher(a); while (matcher.find()) { system.out.println(matcher.group()); }
Comments
Post a Comment