我有一个用^和$表示行首和行尾的模式。
Pattern pattern = Pattern.compile( "^Key2 = (.+)$" );
并且像这样输入:
String text = "Key1 = Twas brillig, and the slithy toves"
+ "\nKey2 = Did gyre and gimble in the wabe."
+ "\nKey3 = All mimsy were the borogroves."
+ "\nKey4 = And the mome raths outgrabe.";
但是
pattern.matcher(text).find()
返回false
。这不应该起作用吗?在Pattern类文档中,概述指定:
边界匹配器 ^ 行的开头 $ 行的结尾