How do I do a regex search and replace in sublime text 2?

谁说我不能喝 提交于 2020-01-09 19:29:13

问题


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

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

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.


回答1:


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)

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

More info here




回答2:


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

style=\"(.*?)\"



回答3:


Find What : style=".*"

Replace With : leave it as blank

Click Replace All button.



来源:https://stackoverflow.com/questions/11733370/how-do-i-do-a-regex-search-and-replace-in-sublime-text-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!