# chs name
# protocol-statistics-enable
# sample
如何通过正则表达式获取 protocol-statistics-enable ?
------解决方案--------------------
- Java code
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)); }