日期:2014-05-20 浏览次数:20785 次
public static void main(String[] args) { // TODO: Add your code here String x=" # chs name\n # protocol-statistics-enable\n # sample"; String regEx="#.+# +([^#]+).+sample"; Pattern p=Pattern.compile(regEx,Pattern.DOTALL); Matcher m=p.matcher(x); boolean rs=m.find(); if (rs) System.out.println(m.group(1)); }