public static final int openedHandle=0x7f010007;
/** Defines panel position on the screen.
<p>Must be one of the following constant values.</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
<tr><td><code>top</code></td><td>0</td><td> Panel placed at top of the screen. </td></tr>
<tr><td><code>bottom</code></td><td>1</td><td> Panel placed at bottom of the screen. </td></tr>
<tr><td><code>left</code></td><td>2</td><td> Panel placed at left of the screen. </td></tr>
<tr><td><code>right</code></td><td>3</td><td> Panel placed at right of the screen. </td></tr>
</table>
*/
public static final int position=0x7f010001;大概是上面这样子,我需要匹配出 openedHandle出来即可。当然实际上我可以先判断每行有没有public static final int这个字符串,有的话就trim一下,在把=号以及后面的去掉,之后再截一下字符串就可以了。但太复杂了有需求才有进步,借此想认真的学一下正则表达式,之前自己学的那些只能匹配简单的。一复杂就不行了
/** Defines panel position on the screen.
<p>Must be one of the following constant values.</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
<tr><td><code>top</code></td><td>0</td><td> Panel placed at top of the screen. </td></tr>
<tr><td><code>bottom</code></td><td>1</td><td> Panel placed at bottom of the screen. </td></tr>
<tr><td><code>left</code></td><td>2</td><td> Panel placed at left of the screen. </td></tr>
<tr><td><code>right</code></td><td>3</td><td> Panel placed at right of the screen. </td></tr>
</table>
*/
public static final int position=0x7f010001;大概是上面这样子,我需要匹配出 openedHandle出来即可。当然实际上我可以先判断每行有没有public static final int这个字符串,有的话就trim一下,在把=号以及后面的去掉,之后再截一下字符串就可以了。但太复杂了有需求才有进步,借此想认真的学一下正则表达式,之前自己学的那些只能匹配简单的。一复杂就不行了
解决方案 »
- 关于javaMail的登录名和发件人的
- 求上传和下载大文本文件功能
- 在netbeans下装struts2插件时遇到头痛
- 为什么调用JCE加密明文之后输出的密文是乱码?
- HttpClient 登录网站问题
- JESS入门
- 用Iterator有什么好处
- 求助!多线程通信问题(tomcat达到最大线程数后,服务不响应)
- 请问怎样用JAVA APPLET编写一个视频播放程序以及使它支持FLASH动画和其他流媒体呢???如果用APPLICATION,那怎样编写呢????
- 求一个将DXF(AutoCAD软件标准)转成SVG(工业矢量图标准)的JAVA代码实现,急,在线等待!
- forEach 同时遍历两个集合求解
- 小菜,求教关于android AutoCompleteTextView的问题
http://www.cnblogs.com/deerchao/archive/2006/08/24/zhengzhe30fengzhongjiaocheng.html
Scanner sc = new Scanner(new FileInputStream("your_file"));
String regex = "(?i).*?public static final int (.*?)\\s*=.*";
Pattern p = Pattern.compile(regex);
while (sc.hasNext()) {
String buf = sc.nextLine();
if (! buf.matches(regex)) continue;
Matcher m = p.matcher(buf);
while (m.find()) System.out.println(m.group(1));
}正则的学习资料,LZ可以参考javadoc的Pattern类,在java.util.regex包里
public static final int (.+)\\s*[=]第二个组里。。虽然我不明白为什么是第二个组而不是第一个组= =