Java RegEx no match found error -
following regex giving me java.lang.illegalstateexception: no match found error
string requestpattern = "^[a-za-z]+ \\/+(\\w+)"; pattern p = pattern.compile(requestpattern); matcher matcher = p.matcher(requeststring); return matcher.group(1); where request string
post //upload/senddata.htm http/1.1 any appreciated.
no match has been attempted. call find() before calling group().
public static void main(string[] args) { string requeststring = "post //upload/senddata.htm http/1.1"; string requestpattern = "^[a-za-z]+ \\/+(\\w+)"; pattern p = pattern.compile(requestpattern); matcher matcher = p.matcher(requeststring); system.out.println(matcher.find()); system.out.println(matcher.group(1)); } output:
true upload
Comments
Post a Comment