字符\0xhh 与具有十六进制值0xhh的字符匹配。
以下示例显示了字符匹配的用法。
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
参考链接
https://www.learnfk.com/javaregex/javaregex-characters-hexa-xhh.html
标签:Java,String,matcher,xhh,无涯,start,static,Pattern,pattern From: https://blog.51cto.com/u_14033984/9049898