求一个正则表达式。另外求正则表达式学习资料
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;
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));}