首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

如其用正则表达式截取字符串

2012-12-23 
如果用正则表达式截取字符串我现在有一段字符:#¥%%哈哈15241ADF*&*%……我现在想截取 哈哈15241ADF 这段字符

如果用正则表达式截取字符串
我现在有一段字符:#¥%%哈哈15241ADF*&*%……
我现在想截取 哈哈15241ADF 这段字符,应该要怎么写?

Pattern pattern = Pattern.compile(".+?\\[(*+?)\\]*+?");
Matcher matcher = pattern.matcher(s);
if (matcher.matches()) {
     String group = matcher.group(1);
System.out.println(group);
} else {
System.out.println("no matches!!");
}
[解决办法]
中文字符也加上去啊。。。客气啥

[0-9a-zA-Z\u4E00-\u9FA5]

热点排行