加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 01:31:03 所属栏目:百科 来源:网络整理
导读: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(re
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;
	}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读