fork download
  1. import java.util.regex.*;
  2.  
  3. class Main
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String str = "(2.5+1)*5";
  8. Pattern p = Pattern.compile("(\\d+\\.?\\d*|\\.\\d+|[^\\d.])");
  9. Matcher m = p.matcher(str);
  10. while (m.find()) {
  11. String match = m.group();
  12. System.out.println(match);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.03s 246656KB
stdin
Standard input is empty
stdout
(
2.5
+
1
)
*
5