简体   繁体   中英

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

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.

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

我有类似的任务要执行,我使用的正则表达式是Nas62建议的方式

style=\"(.*?)\"

Find What : style=".*"

Replace With : leave it as blank

Click Replace All button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM