在数千行代码的随机位置,我想传递以下类型的字符串:
<h3><a href="/question/index?qid=20210417025215AA5DJNX" class="QuestionCard__title___1DKC-">
其中部分20210417025215AA5DJNX
会不时更改为其他类型的字符串:
17/04/2021; 02:52:15
答案1
- Ctrl+H
- 找什么:
<h3><a href="/question/index\?qid=(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d).+
- 用。。。来代替:
LEAVE EMPTY
- 查看 相符
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
<h3><a href="/question/index\?qid= # literally
(\d{4}) # group 1, 4 digits, year
(\d\d) # group 2, 2 digits, month
(\d\d) # group 3, 2 digits, day
(\d\d) # group 4, 2 digits, hour
(\d\d) # group 5, 2 digits, minute
(\d\d) # group 6, 2 digits, second
.+ # 1 or more any character but newline
替代品:
$3/$2/$1; $4:$5:$6
截图(之前):
截图(之后):