架构师之正则表达式(四)---------------从字符串中提取一串数字.

1.前言.
   如题.
2.代码.

	public String getTestString(final String remark) {
             //从字符串中提取一个12位的0-9的数字.
		String strTemp = "";
		if (null == remark) {
			return "";
		}
		final Pattern p = Pattern.compile("[0-9]{12,}+");
		final Matcher m = p.matcher(remark);
		while (m.find()) {
			strTemp = m.group(0);
		}
		return strTemp;
	}

猜你喜欢

转载自nannan408.iteye.com/blog/2158459