当前位置:网站首页>What is the function of the regular expression replaceAll() method?
What is the function of the regular expression replaceAll() method?
2022-08-05 09:32:00 【qq_25073223】
From:
The regular expression replaceAll() methodWhat function does it have?
The following author describes the function introduction of the replaceAll() method, as follows:
The function of the replaceAll() method: Use regular replacement to replace all the matched strings Syntax of the replaceAll() method: Pattern pattern = Pattern.compile("Regular"); //Generate regular expression Matcher matcher = pattern.matcher("regular 122 regular 88988"); //match character matcher.replaceAll("Java")); //replace character
Example:
package com.java265.other;import java.util.regex.Matcher;import java.util.regex.Pattern;public class testClass {/** Use of java265.com Pattern class*/public static void main(String[] args) {Pattern p = Pattern.compile("([a-z]+)");Matcher m1 = p.matcher("java265.com888888");Matcher m2 = p.matcher("java67");System.out.println(m1.replaceAll("Niu Niu"));System.out.println(m1.replaceAll("Niu Niu"));}}-----Run the above code, the following information will be output----Niuniu 265. Niuniu 888888Niu Niu 265. Niu Niu 888888
边栏推荐
猜你喜欢
MySQL内部函数介绍
七夕浪漫约会不加班,RPA机器人帮你搞定工作
ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...
IDEA执行Test操作导致数据插入时出现了重复数据
百行代码发射红心,程序员何愁命不中女朋友!
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
Overall design and implementation of Kubernetes-based microservice project
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
使用 External Secrets Operator 安全管理 Kubernetes Secrets
XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
随机推荐
只有一台交换机,如何实现主从自动切换之nqa
openpyxl to manipulate Excel files
How to realize the short press and long press detection of the button?
Advanced usage of C language
并发之CAS
leetcode 剑指 Offer 10- II. 青蛙跳台阶问题
my journal link
无题十二
阿里云存储的数据库是怎么自动加快加载速度的呢www.cxsdkt.cn怎么设置案例?
无题五
放大器OPA855的噪声计算实例
基于 Kubernetes 的微服务项目整体设计与实现
sql server中 两表查询 平均数 分组
链表中的数字相加----链表专题
七夕浪漫约会不加班,RPA机器人帮你搞定工作
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
手写柯里化 - toString 理解
Embedded practice ---- based on RT1170 transplant memtester to do SDRAM test (25)
The Secrets of the Six-Year Team Leader | The Eight Most Important Soft Skills of Programmers
汇编语言(8)x86内联汇编