当前位置:网站首页>idea正则表达式替换(idea正则搜索)
idea正则表达式替换(idea正则搜索)
2022-07-25 14:06:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
待替换代码如下
(ledger.getPrinciple().intValue() * 100)需要替换成
((int)(ledger.getPrinciple() * 100))我们需要怎么做呢?
- ctrl + r 打开文件替换
- 勾选替换选项Regex
- 待匹配行正则表达式逐步分解
- 首先我们看到有三个括号,一个
* 100,于是有了\(\(\)\(\) \* 100\),特殊字符一定要用转义符 - 上述表达式肯定匹配不到内容的,需要加上字母/符号的匹配,
\(.+\(\).+\(\) \* 100\) - 正则表达式已经匹配上,但我们还要将我们需要的字符串取出来,也就是
ledger.getPrinciple(),用小括号括上,于是有了\((.+\(\)).+\(\) \* 100\) - 替换后代码:((int) (1 * 100)) , 1 被替换成第6步里面的那一串ledger.getPrinciple()
简单解释下:
- 不带\(的第一个括号是将其提取,后会在1(依次类推 2,
- 其他没有什么特别的,需要稍微有一些正则匹配基础知识
- 重点是在待替换的字符串中找到特殊的关键字符,比如上述的
(),* 100等
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127658.html原文链接:https://javaforall.cn
边栏推荐
- Detailed explanation of nat/napt address translation (internal and external network communication) technology [Huawei ENSP]
- Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
- Four methods of importing CSV text files into Excel
- Brush questions - Luogu -p1152 happy jump
- 【目录爆破工具】信息收集阶段:robots.txt、御剑、dirsearch、Dirb、Gobuster
- 手把手教学Yolov7的搭建及实践
- Brush questions - Luogu -p1150 Peter's smoke
- leetcode--四数相加II
- @Wrap decorator
- 【力扣】1030.距离顺序排列矩阵单元格
猜你喜欢

Mxnet implementation of densenet (dense connection network)

~4.1 sword finger offer 05. replace spaces

The practice of depth estimation self-monitoring model monodepth2 in its own data set -- single card / multi card training, reasoning, onnx transformation and quantitative index evaluation

From Anaconda to tensorflow to jupyter, step on the pit and fill it all the way

手把手教你申请SSL证书

Nuc980 set up SSH xshell connection

2271. Maximum number of white bricks covered by blanket ●●

~5 new solution of CCF 2021-12-2 sequence query

leetcode--四数相加II

Common problems in the use of wireless vibrating wire acquisition instrument
随机推荐
Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]
Brush questions - Luogu -p1075 prime factor decomposition
MySQL and Navicat installation and stepping on pits
【力扣】645.错误的集合
Amd epyc 9664 flagship specification exposure: 96 core 192 threads 480MB cache 3.8ghz frequency
Interpretation of featdepth self-monitoring model for monocular depth estimation (Part I) -- paper understanding and core source code analysis
Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process
Mysql表的操作
Namespaces and libraries
Detailed explanation of how R language converts large Excel files into DTA format
Pytorch uses tensorboard to realize visual summary
How happy is the frisbee bureau? 2022 youth trendy Sports Report
CDA level Ⅰ 2021 new version simulation question 1 (with answers)
What problems should SEOER pay attention to when baidu searches and attacks pirated websites?
Common problems of wireless relay acquisition instrument
[force buckle] 645. Wrong set
Alibaba mqtt IOT platform "cloud product circulation" practice - the two esp32 achieve remote interoperability through the IOT platform
科隆新能源IPO被终止:拟募资6亿 先进制造与战新基金是股东
leetcode202---快乐数
Business data analysis of CDA level1 knowledge point summary