Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use regexp as variables to do find and replace in sublime text?

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?

like image 944
Himmators Avatar asked Jul 15 '12 12:07

Himmators


People also ask

Can you use regex in Find and Replace?

When you want to search and replace specific patterns of text, use regular expressions. They can help you in pattern matching, parsing, filtering of results, and so on. Once you learn the regex syntax, you can use it for almost any language. Press Ctrl+R to open the search and replace pane.

Does Sublime Text support regex?

Search functions in Sublime Text support regular expressions, a powerful tool for searching and replacing text. Regular Expressions find complex patterns in text.

How do I find and replace in Sublime Text?

Or, if you want to find and replace text in a number of files at once, press Command + Shift + F or Control + Shift + H to open Sublime Text's Find in Files tool that can search and replace across as many files as you have open or select from its menu.

How do I match a number in regex?

\d for single or multiple digit numbers To match any number from 0 to 9 we use \d in regex. It will match any single digit number from 0 to 9. \d means [0-9] or match any number from 0 to 9. Instead of writing 0123456789 the shorthand version is [0-9] where [] is used for character range.


1 Answers

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

This example will remove the ' and the ,

like image 134
Thorbear Avatar answered Nov 08 '22 19:11

Thorbear