fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.Pattern;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. private static final Pattern ALL_NON_NUMERICS_EXCEPT_LEADING_MINUS_AND_E_AND_LAST_DOT_OR_COMMA = Pattern.compile("[^\\d,.\\-+eE]|(?<!(^|[eE]))\\s*[+\\-]|[eE](?!\\s*[+\\-]?\\s*\\d+$)|[.,](?=.*[.,])");
  12.  
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. var intermediate = ALL_NON_NUMERICS_EXCEPT_LEADING_MINUS_AND_E_AND_LAST_DOT_OR_COMMA
  16. .matcher("3 e -9")
  17. .replaceAll("");
  18.  
  19. System.out.println(intermediate);
  20. }
  21. }
Success #stdin #stdout 0.09s 48336KB
stdin
Standard input is empty
stdout
3e9