JAVA-替换字符串非数字字符

JAVA中替换字符串里的非数字字符,最简单的方法,使用正则表达式:

/**
 * @author wzx
 * @time 2018/8/4
 */
public class StringNumberFilterTest {
    public static void main(String[] args) {
        String s = "wang...test4.jpg".replaceAll("[^\\d]", "");
        System.out.println(s);
    }
}

输出结果:

4

猜你喜欢

转载自blog.csdn.net/wang704987562/article/details/81409321
今日推荐