字符\0uhhhh 与具有Unicode值0uhhhh的字符匹配。
以下示例显示了字符匹配的用法。
package com.learnfk; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CharactersDemo { private static final String REGEX = "\\u0041"; private static final String INPUT = "abcAabc"; public static void main(String[] args) { //create a pattern Pattern pattern = Pattern.compile(REGEX); //get a matcher object Matcher matcher = pattern.matcher(INPUT); if(matcher.find()) { //Prints the start index of the match. System.out.println("Match String start(): "+matcher.start()); } } }
让我们编译并运行以上程序,这将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/javaregex/javaregex-characters-unicode-uhhhh.html
来源:LearnFk无涯教程网
Match String start(): 3
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)