如何在崇高的文本2中进行regex搜索和替换?

时间:2022-05-25 16:49:22

I want to remove inline style from an html document in ST2.

我想从ST2中的html文档中删除内联样式。

I imagine my regex will be something like this style=\"*\"

我想我的regex将会是这样的样式=\"*\"

If that's wrong, it doesn't matter. I'm sure I'll figure out the expression I'll need.

如果这是错的,也没关系。我肯定我会找到我需要的表达式。

What I haven't been able to figure out, is how to actually use a regex to find or to find and replace text in ST2. The docs say that it can be done. But I can't find the documentation for how to do it.

我还没能弄清楚的是,如何使用正则表达式来查找或替换ST2中的文本。医生说这是可以做到的。但是我找不到怎么做的文档。

3 个解决方案

#1


12  

Simply open the Search+Replace function (via Ctrl-H or the menu bar) and check the first box on the left of it (the one with an '*' on it, or you can press Alt+R)

只需打开Search+Replace函数(通过Ctrl-H或菜单栏),并选中左侧的第一个框(上面有'*',或者按Alt+R)

Then the search field will be used as a Regex, and you can use the found patterns using the usual $1, $2, $3 vars in the replace box

然后搜索字段将用作Regex,您可以使用替换框中常见的$1、$2、$3 vars使用找到的模式

More info here

更多的信息在这里

#2


12  

I had a similar task to perform, the regex I used in the manner that Nas62 suggested was

我有一个类似的任务要做,我使用的regex就像Nas62建议的那样

style=\"(.*?)\"

#3


1  

Find What : style=".*"

Replace With : leave it as blank

发现什么:= "风格。用:保持为空

Click Replace All button.

点击替换所有按钮。

#1


12  

Simply open the Search+Replace function (via Ctrl-H or the menu bar) and check the first box on the left of it (the one with an '*' on it, or you can press Alt+R)

只需打开Search+Replace函数(通过Ctrl-H或菜单栏),并选中左侧的第一个框(上面有'*',或者按Alt+R)

Then the search field will be used as a Regex, and you can use the found patterns using the usual $1, $2, $3 vars in the replace box

然后搜索字段将用作Regex,您可以使用替换框中常见的$1、$2、$3 vars使用找到的模式

More info here

更多的信息在这里

#2


12  

I had a similar task to perform, the regex I used in the manner that Nas62 suggested was

我有一个类似的任务要做,我使用的regex就像Nas62建议的那样

style=\"(.*?)\"

#3


1  

Find What : style=".*"

Replace With : leave it as blank

发现什么:= "风格。用:保持为空

Click Replace All button.

点击替换所有按钮。