是否可以使用regexp作为变量在sublime文本中进行查找和替换?

时间:2022-02-18 02:24:25

I have a regexp search that looks like this:

我有一个正则表达式搜索,如下所示:

'\d*.\d*, \d*.\d*'

I want to change the ' and the ,, but keep the d*. Is this possible in sublime text? If not, what's the easiest way to do this?

我想改变'和,,但保持d *。在崇高文本中这可能吗?如果没有,最简单的方法是什么?

1 个解决方案

#1


30  

This works the same way as most other places where regular expressions are available;

这与大多数其他正则表达式可用的地方的工作方式相同;

Group the parts of the pattern that you want to keep, and reference them in the replacement

将要保留的模式部分分组,并在替换中引用它们

Pattern: '(\d*.\d*), (\d*.\d*)' Replacement: $1 $2

模式:'(\ d *。\ d *),(\ d *。\ d *)'替换:$ 1 $ 2

This example will remove the ' and the ,

这个例子将删除'和,

#1


30  

This works the same way as most other places where regular expressions are available;

这与大多数其他正则表达式可用的地方的工作方式相同;

Group the parts of the pattern that you want to keep, and reference them in the replacement

将要保留的模式部分分组,并在替换中引用它们

Pattern: '(\d*.\d*), (\d*.\d*)' Replacement: $1 $2

模式:'(\ d *。\ d *),(\ d *。\ d *)'替换:$ 1 $ 2

This example will remove the ' and the ,

这个例子将删除'和,