1 import java.util.regex.Matcher;
2 import java.util.regex.Pattern;
3 public class RegexDemo {
4 public static void main(String[] args) {
5 String str="A1B22C333D4444E55555";
6 String pat="\\d+";
7 Pattern p=Pattern.compile(pat);
8 Matcher m=p.matcher(str);
9 String newS=m.replaceAll("_");
10 System.out.print(newS);
11 }
12 }