当前位置:网站首页>正则表达式replaceFirst()方法具有什么功能呢?
正则表达式replaceFirst()方法具有什么功能呢?
2022-08-05 09:16:00 【qq_25073223】
转自:
下文笔者讲述replaceFirst()方法的功能简介说明,如下所示:
replaceFirst()方法的功能: 使用正则替换匹配出的第一个匹配出的字符串 replaceFirst()方法的语法: Pattern pattern = Pattern.compile("正则"); //生成正则表达式 Matcher matcher = pattern.matcher("正则122正则88988"); //匹配字符 matcher.replaceFirst("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 pattern = Pattern.compile("正则"); //生成正则表达式
Matcher matcher = pattern.matcher("正则122正则88988"); //匹配字符
System.out.println(matcher.replaceFirst("Java")); // 替换字符
}
}
------运行以上代码,将输出以下信息-----
Java122正则88988边栏推荐
- eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
- openpyxl操作Excel文件
- How to realize the short press and long press detection of the button?
- egg framework
- Creo 9.0 基准特征:基准平面
- leetcode 剑指 Offer 10- I. 斐波那契数列
- 512-color chromatogram
- 画法几何及工程制图考试卷A卷
- 无题十二
- The Secrets of the Six-Year Team Leader | The Eight Most Important Soft Skills of Programmers
猜你喜欢

Example of Noise Calculation for Amplifier OPA855

sql server中 两表查询 平均数 分组

Creo 9.0 基准特征:基准轴

DPU — 功能特性 — 网络系统的硬件卸载

Embedded practice ---- based on RT1170 transplant memtester to do SDRAM test (25)

Creo 9.0 基准特征:基准平面

如何实现按键的短按、长按检测?

让程序员崩溃的N个瞬间(非程序员误入)

Creo 9.0 基准特征:基准坐标系

Thinking and summary of the efficiency of IT R&D/development process specification
随机推荐
无题十一
SQL语句查询字段内重复内容,并按重复次数加序号
无题二
CVPR 2022 | 将X光图片用于垃圾分割,港中大(深圳)探索大规模智能垃圾分类
【Excel实战】--图表联动demo_001
js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
PAT乙级-B1019 数字黑洞(20)
Creo 9.0 基准特征:基准平面
按钮上显示值的轮流切换
Rotation of the displayed value on the button
营销建议 | 您有一份八月营销月历待查收! 建议收藏 !
CCVR基于分类器校准缓解异构联邦学习
DPU — 功能特性 — 安全系统的硬件卸载
C语言-数组
Why do I recommend using smart async?
Is there a problem with writing this?How to synchronize data in sql-client
Example of Noise Calculation for Amplifier OPA855
sql server收缩日志的作业和记录,失败就是因为和备份冲突了吗?
微信小程序请求封装
无题十