字符\0xhh 与具有十六进制值0xhh的字符匹配。
以下示例显示了字符匹配的用法。
链接:https://www.learnfk.comhttps://www.learnfk.com/javaregex/javaregex-characters-hexa-xhh.html
来源:LearnFk无涯教程网
package com.learnfk; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CharactersDemo { private static final String REGEX = "\\x41"; 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()); } } }
让我们编译并运行以上程序,这将产生以下输出-
Match String start(): 3
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)