站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题java正则表达式,选取所有字符的问题?

java正则表达式,选取所有字符的问题?

摘要: java正则表达式,选取所有字符的问题?


怎么能够匹配所有字符包括空白字符回车等
试过
([^a]|[a])*
(/s|/S)*
不行


ding


[./n]*


[./n]*
这个也不行!

<(.*)>.*
这个只能匹配同一行的HTML 标记,我希望匹配多行的
怎么实现,用java???


试试这个应该可以

String src = "...很多行.....";
String regx = "[ |//S]*"; //注/S匹配非空格字符,
Pattern p = Pattern.compile(rex);
Matcher m = p.matcher(src);
while (m.find()) {
System.out.println(m.group());
}


所有字符除去换行就用
(.+?)


试试 这个
(.|/n)*?


需要指定匹配模式,就是下面的常量

Pattern.compile(rex, CONSTANT_XXX);

CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, and CANON_EQ


Compiles the given regular expression into a pattern with the given flags.

Parameters:
regex The expression to be compiled
flags Match flags, a bit mask that may include CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, and CANON_EQ
Throws:
IllegalArgumentException If bit values other than those corresponding to the defined match flags are set in flags
PatternSyntaxException If the expression's syntax is invalid


↑返回目录
前一篇: 请问,解压文件操作,一个RAR文件,我如何用程序来解压它,需要涉及到哪些关键类,谢谢~~!!
后一篇: JDBC连接SQL SERVER 2000报拒绝