fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String rx = "\\B(?<!\\d)\\d\\b";
  11. System.out.println("I am the number1".replaceAll(rx, ""));
  12. // => I am the number
  13. System.out.println("I am the number11".replaceAll(rx, ""));
  14. // => I am the number11
  15. System.out.println("I am 4the number1 @#@%$grtuy".replaceAll(rx, ""));
  16. // => I am 4the number @#@%$grtuy
  17. System.out.println("I am number1 1 and you number2 2".replaceAll(rx, ""));
  18. // => I am number 1 and you number 2
  19. }
  20. }
Success #stdin #stdout 0.07s 33656KB
stdin
Standard input is empty
stdout
I am the number
I am the number11
I am 4the number @#@%$grtuy
I am number 1 and you number 2