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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -