我正在学习正则表达式,我有这段代码:
private static final String FILE_BEGINNING_PATTERN = "^(,Share %)";
public static void main(String[] args) {
String str = ",Share %,\"Date Purchased\",Display Name,Address,Phone,Fax,Mobile,Email,";
Matcher beginningFileMatcher = Pattern.compile(FILE_BEGINNING_PATTERN).matcher(str);
if (beginningFileMatcher.find()) {
System.out.println("Regex match!");
}
// find() method starts at the beginning of this matcher's region, or, if
// a previous invocation of the method was successful and the matcher has
// not since been reset, at the first character not matched by the previous
// match.
//
int count = 0;
while …Run Code Online (Sandbox Code Playgroud) 我正在学习 String intern() 方法并且知道 intern() 帮助我可以使用“==”运算符来比较 String 对象而不是 equals() 方法,并且一些文档更快地引用了它。不是吗?