当前位置:网站首页>正则表达式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边栏推荐
- CCVR基于分类器校准缓解异构联邦学习
- js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
- 在colab里怎样读取google drive数据
- 基于 Kubernetes 的微服务项目整体设计与实现
- Undefined symbols for architecture arm64解决方案
- Xcode 12 ld: symbol(s) not found for architecture armv64
- Creo 9.0 基准特征:基准平面
- eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
- 无题七
- There is only one switch, how to realize the nqa of master-slave automatic switching
猜你喜欢

21 Days of Deep Learning - Convolutional Neural Networks (CNN): Weather Recognition (Day 5)

DTcloud 装饰器

使用HBuilder离线本地打包ipa教程

代码审计—PHP

深度学习21天——卷积神经网络(CNN):天气识别(第5天)

shell脚本实例

js graphics operation one (compatible with pc, mobile terminal to achieve draggable attribute drag and drop effect)

为什么我推荐使用智能化async?

2.4G无线收发模块的应用

sql server中 两表查询 平均数 分组
随机推荐
seata源码解析:事务状态及全局锁的存储
ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...
Undefined symbols for architecture arm64解决方案
科普大佬说 | 港大黄凯斌老师带你解锁黑客帝国与6G的关系
IT研发/开发流程规范效能的思考总结
16 kinds of fragrant rice recipes
Happens-before rules for threads
openpyxl to manipulate Excel files
Why do I recommend using smart async?
XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
按钮上显示值的轮流切换
阿里云存储的数据库是怎么自动加快加载速度的呢www.cxsdkt.cn怎么设置案例?
施一公:科学需要想象,想象来自阅读
Walk 100 trick society
Linux导出数据库数据到硬盘
在colab里怎样读取google drive数据
Thinking and summary of the efficiency of IT R&D/development process specification
21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
好资料汇总
2022-08-01 回顾基础二叉树以及操作