码迷,mamicode.com
首页 > 其他好文 > 详细

正则取出值

时间:2019-01-27 16:28:56      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:表达式   find   正则   new   system   表达   compile   stat   param   

/** * 正则表达式匹配两个指定字符串中间的内容 * @param soap * @return */ public static List<String> getSubUtil(String soap, String rgex){ List<String> list = new ArrayList<String>(); Pattern pattern = Pattern.compile(rgex);// 匹配的模式 Matcher m = pattern.matcher(soap); while (m.find()) { int i = 1; list.add(m.group(i)); i++; } return list; } ========================== String regs = "\"actId\":\"(\\d+)\""; List<String> subUtil = getSubUtil(s, regs); System.out.println(subUtil);

正则取出值

标签:表达式   find   正则   new   system   表达   compile   stat   param   

原文地址:http://blog.51cto.com/357712148/2347049

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!