Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 874
cjgxkneq Avatar asked Jul 31 '12 04:07

cjgxkneq


People also ask

How do I find and replace in Sublime Text?

How to Find and Replace in Sublime Text 3 1 Find and Replace all Matches in a File. This will open the Find and Replace Console at the bottom of the window. ... 2 Find and Replace all Matches Across Multiple Files. ... 3 Regex Find and Replace. ... 4 Case Sensitive Matching. ... 5 Whole Word Matching. ...

How do I use regex in Sublime Text?

Regex Find and Replace To enable RegEx pattern matching in Sublime Text, click on the.* button on the far-left hand side of the find console window. Alternatively, you can use the key combination CMD + OPT + R on macOS and CTRL + ALT + R on Windows/Linux while the console is the active window.

What is find and replace in a text editor?

Find and Replace is a simple mechanism available in any serious text editor and also word processors and design layout applications. Find and Replace at its most basic has two fields: FIND – A set and arrangement of text characters that you are specifically looking for within a defined range of text or a document.

How do I use regular expressions in find and replace?

Before we start employing Regular Expressions in the Find and Replace panel, we need to enable Regular Expressions by clicking a button by that name, which is the left-most top button in the Find and Replace panel: With the Regular Expressions mode activated, this is what I put in the FIND field to isolate that space in that particular location:


2 Answers

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

like image 64
Naps62 Avatar answered Sep 28 '22 03:09

Naps62


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

style=\"(.*?)\"
like image 37
supajb Avatar answered Sep 28 '22 04:09

supajb