当前位置:网站首页>正则表达式replaceAll()方法具有什么功能呢?
正则表达式replaceAll()方法具有什么功能呢?
2022-08-05 09:16:00 【qq_25073223】
转自:
下文笔者讲述replaceAll()方法的功能简介说明,如下所示:
replaceAll()方法的功能: 使用正则替换匹配出的所有字符串 replaceAll()方法的语法: Pattern pattern = Pattern.compile("正则"); //生成正则表达式 Matcher matcher = pattern.matcher("正则122正则88988"); //匹配字符 matcher.replaceAll("Java")); //替换字符 例:
package com.java265.other;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class testClass {
/*
* java265.com Pattern类的使用
*/
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("牛牛"));
System.out.println(m1.replaceAll("牛牛"));
}
}
-----运行以上代码,将输出以下信息----
牛牛265.牛牛888888
牛牛265.牛牛888888边栏推荐
- js graphics operation one (compatible with pc, mobile terminal to achieve draggable attribute drag and drop effect)
- sql server收缩日志的作业和记录,失败就是因为和备份冲突了吗?
- CCVR eases heterogeneous federated learning based on classifier calibration
- sphinx matches the specified field
- PAT Level B - B1021 Single Digit Statistics (15)
- 营销建议 | 您有一份八月营销月历待查收! 建议收藏 !
- 放大器OPA855的噪声计算实例
- Embedded practice ---- based on RT1170 transplant memtester to do SDRAM test (25)
- 无题十
- 随时牵手 不要随意分手[转帖]
猜你喜欢
随机推荐
工程制图直线投影练习
无题三
请问如果想往mysql里面写数据,直接用flink-connector-jdbc就可以吧,可是我在f
【zeno】为zeno增加子模块/新节点的最小化的例子
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
我的杂记链接
基因数据平台
Assembly language (8) x86 inline assembly
好资料汇总
【LeetCode】623. 在二叉树中增加一行
SQL语句查询字段内重复内容,并按重复次数加序号
Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
egg framework
HStreamDB Newsletter 2022-07|分区模型优化、数据集成框架进一步完善
C语言-数组
Xcode 12 ld: symbol(s) not found for architecture armv64
The Secrets of the Six-Year Team Leader | The Eight Most Important Soft Skills of Programmers
使用稀疏 4D 卷积对 3D LiDAR 数据中的运动对象进行后退分割(IROS 2022)
Code Audit - PHP
无题一









