Java中用正则表达式找出数字
1、题目
String str = "fjd789klsd908434jk#$$%%^38488545",从中找出78990843438488545,请找到解决办法
2、实现源码
/**
*
*/
package com.you.model;
/**
* @author YouHaidong
*
*/
public class FindNumber
{
/**
* 字符串str
*/
public static String str = "fjd789klsd908434jk#$$%%^38488545";
/**
* @param args
*/
public static void main(String[] args)
{
System.out.println("替换之前的字符串:" + str);
String substr = str.replaceAll("[^0-9]", "");
System.out.println("替换之后的字符串:" + substr);
}
}
3、结果
替换之前的字符串:fjd789klsd908434jk#$$%%^38488545
替换之后的字符串:78990843438488545