java - Regexp to match full Exception name -


i need regexp whole exception name incl. dots stacktrace , it's whitespace before it.

time: sun apr 10 20:36:57 cest 2011 message: java.lang.nullpointerexception    @ com.hello.world.hi.initdb(bla.java:273) 

something :

string test = "time: sun apr 10 20:36:57 cest 2011\nmessage: java.lang.nullpointerexception\n   @ com.hello.world.hi.initdb(bla.java:273)"; pattern check = pattern.compile(".*message:(\\s[\\w\\.]*)"); matcher checker = check.matcher(test); while(checker.find()) {     system.out.println(checker.group(1)); } 

output

 java.lang.nullpointerexception 

update

ok, if want match "exception" word - there way:

string test = "time: sun apr 10 20:36:57 cest 2011\nmessage: java.lang.nullpointerexception\n   @ com.hello.world.hi.initdb(bla.java:273)"; pattern check = pattern.compile("(\\s[\\w\\.]*exception)"); matcher checker = check.matcher(test); while(checker.find()) {    system.out.println(checker.group(1)); } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -