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性能调优实战 -〔刘超〕

从0打造音视频直播系统 -〔李超〕

网络编程实战 -〔盛延敏〕

.NET Core开发实战 -〔肖伟宇〕

Serverless入门课 -〔蒲松洋(秦粤)〕

乔新亮的CTO成长复盘 -〔乔新亮〕

跟着高手学复盘 -〔张鹏〕

如何讲好一堂课 -〔薛雨〕

Go进阶 · 分布式爬虫实战 -〔郑建勋〕

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