当前位置:网站首页>正则表达式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边栏推荐
- Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
- Concurrent CAS
- seata源码解析:TM RM 客户端的初始化过程
- Thinking and summary of the efficiency of IT R&D/development process specification
- Happens-before rules for threads
- There is only one switch, how to realize the nqa of master-slave automatic switching
- 使用稀疏 4D 卷积对 3D LiDAR 数据中的运动对象进行后退分割(IROS 2022)
- 为什么我推荐使用智能化async?
- Overall design and implementation of Kubernetes-based microservice project
- 新白娘子传奇系列
猜你喜欢

【LeetCode】623. 在二叉树中增加一行

施一公:科学需要想象,想象来自阅读

【ASM】字节码操作 方法的初始化 Frame

链表中的数字相加----链表专题

eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑

Seata source code analysis: initialization process of TM RM client

并发之CAS

MySQL内部函数介绍

Example of Noise Calculation for Amplifier OPA855

How to realize the short press and long press detection of the button?
随机推荐
(转)[Json]net.sf.json 和org.json 的差别及用法
Xcode10的打包方式distribute app和启动项目报错以及Xcode 打包本地ipa包安装到手机上
让程序员崩溃的N个瞬间(非程序员误入)
并发之CAS
如何实现按键的短按、长按检测?
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
使用 External Secrets Operator 安全管理 Kubernetes Secrets
Two-table query average grouping in sql server
my journal link
DPU — 功能特性 — 存储系统的硬件卸载
Creo 9.0 基准特征:基准坐标系
Neuron Newsletter 2022-07|新增非 A11 驱动、即将支持 OPC DA
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
seata源码解析:事务状态及全局锁的存储
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
CPU的亲缘性affinity
Rotation of the displayed value on the button
手把手教你纯c实现异常捕获try-catch组件
HStreamDB Newsletter 2022-07|分区模型优化、数据集成框架进一步完善