【发布时间】:2015-02-25 14:12:05
【问题描述】:
我正在尝试使用 regExp 来获取括号之间的值: 例如:
<td width=40><input type=\"button\" OnClick='FullScreen(1)' value=\" 1\" size=80></td>
<td width=(40)><input type=\"button\" OnClick='FullScreen(2)' value=\" 1\" size=80></td>
<td width=40><input type=\"button\" OnClick='FullScreen(3)' value=\" 1\" size=80></td>
<td width=40><input type=\"button\" OnClick='FullScreen(4)' value=\" 1\" size=80></td>
我想在本例中检索全屏的值 1、2、3 和 4
我试试这个正则表达式:
Pattern p = Pattern.compile("\\((.*?)\\)");
Matcher m = p.matcher(String);
if(m.find()){
System.out.println("val = " +m.group(1));
}
但这会检索括号之间的所有值,我如何才能只从全屏字符串中获取值?
谢谢
【问题讨论】:
-
所有 4 行都是同一个字符串的一部分,还是它们是单独的字符串?