首页 > 解决方案 > 我需要一个正则表达式来替换语法

问题描述

我是 sublime text3 的新手,但开始喜欢在其中工作。

我正在使用它的搜索和替换来实现如下:

我有一个数百个项目的列表,如下所示:

第5149章
第5427章
5036:卡洛乔里奥卡普提
5071:卡洛·乔里奥·斯莱斯
第5466章

但我想用

5149-
5427-
5036-
5071-
5466-

所以基本上冒号和单词应该用连字符(-)符号替换

我尝试了一些正则表达式。例如: (?<=WORD).*$

但事情不正常。

标签: sublimetext3

解决方案


I tried myself and finally got the expression that works for my requirement.

In the find area type:

 : [a-zA-Z\d" "]+

And in the replace area type:

-

This gives you the numbers followed by a hiphen and eliminating the words.


推荐阅读