[color=blue][size=x-large]A sample:[/size][/color]
[img]http://dl.iteye.com/upload/attachment/222480/7337b05e-6d43-3c8e-8b34-f4806278d7a1.png[/img]
------------------------------------------------------------
[color=blue][size=x-large]正则表达式查询表:[/size][/color]
[img]http://dl.iteye.com/upload/attachment/222472/b9c2e99b-c0e0-31f9-b94f-05b087b6da03.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/222480/7337b05e-6d43-3c8e-8b34-f4806278d7a1.png[/img]
/**
* description: 取出上图中的单词列表,其他没用的就不要了<br>
* @param args
* Mar 22, 2010
* @author huxiao kskr@qq.com
*/
public static void main(String[] args) {
String testString = "String(fjsi fj\"this is my target word\"lsd jflks)";
Matcher matcher = Pattern.compile("w\\(\\d+,\"[^\"]+\",\"([^\"]+)\"").matcher(testString);
if(matcher.find()){
System.out.println(matcher.group(1));
}
}
------------------------------------------------------------
[color=blue][size=x-large]正则表达式查询表:[/size][/color]
[img]http://dl.iteye.com/upload/attachment/222472/b9c2e99b-c0e0-31f9-b94f-05b087b6da03.jpg[/img]
本文通过一个具体的示例介绍了如何使用Java中的正则表达式来从字符串中提取特定的单词。示例中详细展示了匹配模式的定义及其实现过程。
1万+

被折叠的 条评论
为什么被折叠?



