Note on match() method of String class in Java

The match() method in the String class inputs abc, which can only match the string whose entire string is abc, and if there is abc in the string, it cannot be matched;

And using this method can successfully match the abc in abcd:

	Pattern p = Pattern.compile("abc");
	Matcher m = p.matcher("abcd"); 
	while(m.find()){
    
     
		System.out.println(m.group());//abc 
	}

Guess you like

Origin blog.csdn.net/qq_43665244/article/details/113887685