【发布时间】:2018-07-05 22:22:24
【问题描述】:
1.基于此代码https://docs.oracle.com/javase/tutorial/essential/regex/test_harness.html
谁能解释一下这个 \"%s\" in
while (matcher.find()) {
console.format("I found the text" + " \"%s\" starting at " +
"index %d and ending at index %d.%n",
matcher.group(),
matcher.start(),
matcher.end());
found = true;
}
我只知道%s 是字符串。
2.引用元字符https://docs.oracle.com/javase/tutorial/essential/regex/literals.html这个输出有什么解释吗?
【问题讨论】:
-
%s一个格式化字符,用于基于格式的打印,与正则表达式本身无关。 APIhere.
标签: java pattern-matching metacharacters