子表达式/元字符“^”匹配行首。如果在正则表达式中使用它,它将匹配输入字符串中紧随其后的句子。示例 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample { public static void main( String args[] ) { String regex = "^Hi how are you"; String input = "Hi how are you welcome to Tutorialspoint"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(input); int count = 0; while(m.find()) { count++; ... 阅读更多