当前位置:网站首页>What is the function of the regular expression replaceFirst() method?
What is the function of the regular expression replaceFirst() method?
2022-08-05 09:32:00 【qq_25073223】
From:
The regular expression replaceFirst() methodWhat function does it have?
The following author describes the function introduction of the replaceFirst() method, as follows:
The function of the replaceFirst() method: Use regular replacement to match the first matched string. The syntax of the replaceFirst() method: Pattern pattern = Pattern.compile("regular"); //Generate regular expression Matcher matcher = pattern.matcher("regular 122 regular 88988"); //match character matcher.replaceFirst("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 pattern = Pattern.compile("regular"); //Generate regular expressionMatcher matcher = pattern.matcher("regular 122 regular 88988"); //match charactersSystem.out.println(matcher.replaceFirst("Java")); // replace character}}------Run the above code, the following information will be output-----Java122 regular 88988
边栏推荐
- matcher中find,matches,lookingAt匹配字符串的不同之处说明
- 无题十二
- 阿里云存储的数据库是怎么自动加快加载速度的呢www.cxsdkt.cn怎么设置案例?
- eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
- There is only one switch, how to realize the nqa of master-slave automatic switching
- 【ASM】字节码操作 方法的初始化 Frame
- 七夕浪漫约会不加班,RPA机器人帮你搞定工作
- leetcode points to Offer 10- I. Fibonacci sequence
- Dry goods!Generative Model Evaluation and Diagnosis
- 轩辕实验室丨欧盟EVITA项目预研 第一章(四)
猜你喜欢
C语言的高级用法
深度学习21天——卷积神经网络(CNN):天气识别(第5天)
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
Assembly language (8) x86 inline assembly
leetcode: 529. 扫雷游戏
XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
Redis源码解析:Redis Cluster
七夕浪漫约会不加班,RPA机器人帮你搞定工作
Two-table query average grouping in sql server
Hundred lines of code launch red hearts, why programmers lose their girlfriends!
随机推荐
5.部署web项目到云服务器
What is CRM Decision Analysis Management?
Assembly language (8) x86 inline assembly
我的杂记链接
C语言-数组
科普大佬说 | 港大黄凯斌老师带你解锁黑客帝国与6G的关系
my journal link
Oracle临时表空间作用
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
2022-08-01 Review the basic binary tree and operations
Going to book tickets tomorrow, ready to go home~~
The Seven Weapons of Programmers
明天去订票,准备回家咯~~
leetcode refers to Offer 10- II. Frog jumping steps
pytorch余弦退火学习率CosineAnnealingLR的使用
XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
Weekly Report 2022-8-4
The technological achievements of Shanghai Konan were selected into the "2021 Shanghai Network Security Industry Innovation Research Achievement Catalog" by the Municipal Commission of Economy and Inf
ffmpeg drawtext add text watermark
仿SBUS与串口数据固定转换