Java 正则 中的 characters \xhh 匹配

首页 / 正则入门教程 / Java 正则 中的 characters \xhh 匹配

字符\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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

Java核心技术面试精讲 -〔杨晓峰〕

算法面试通关40讲 -〔覃超〕

TensorFlow快速入门与实战 -〔彭靖田〕

设计模式之美 -〔王争〕

数据中台实战课 -〔郭忆〕

Kafka核心源码解读 -〔胡夕〕

Flink核心技术与实战 -〔张利兵〕

操作系统实战45讲 -〔彭东〕

快手 · 移动端音视频开发实战 -〔展晓凯〕

好记忆不如烂笔头。留下您的足迹吧 :)