.*可匹配所有字符,不包括换行符,如何写匹配包括多个换行符的表达式呢?
比如匹配如下一段字符串:
throws InvocationTargetException,
IllegalAccessException, RemoteException,
HibernateException,Exception {
谢谢了!
------解决方案--------------------
你想以什么符号匹配呀?逗号吗?
------解决方案--------------------
(.*\r\n)+
------解决方案--------------------
试试这个,呵呵:
(?s:.*)
------解决方案--------------------
(.*(\r\n)*)+
------解决方案--------------------
通常,使用 SINGLELINE 模式时, ". " 就可以匹配换行符。
javascript 的 regexp 不支持 SINGLELINE 模式。
可以使用 (.|\n)
推荐文章:
http://www.regexlab.com/zh/regref.htm
------解决方案--------------------
"[\\x00-\\xff]* "
------解决方案--------------------
up
------解决方案--------------------
up
------解决方案--------------------
String patternString = ". ";
Pattern pattern = Pattern.compile(patternString, Pattern.DOTALL);
------解决方案--------------------
Pattern pat = Pattern.compile( ".*[\n]* ");
Matcher mat = pat.matcher(str);