tiagomac
tiagomac

Reputation: 481

Sublime Text2 how to replace with parameter?

I have a text like: "test 1 test 2 test 3" and i want to replace to something like: "test d1 test d2 test d3", for this i think that i can use a regex: "\d" and then in the replace use "d(parameter)" so i can catch the number 1, 2 and 3. it is possible in sublime text 2 like is in notepad++ or editplus?

Upvotes: 3

Views: 7860

Answers (2)

sebast26
sebast26

Reputation: 1792

In Ctrl + H (Replace...) you should enable Regular expression (Alt+R) and then you should use

\d+

in Find What and

d$0

in Replace With

Upvotes: 6

buckley
buckley

Reputation: 14119

Sublime is a prety recent editor AFAIK so it will have a decent regex engine on board lets hope

Your question is maybe a simplification and I think I read that you want to replace test plus a number with the same thing but prefix it with a d

regex

test (\d+)

replace with

test d$1

If they need to come in groups of 3 its rather easy to tweak. Let us know if you can go ahead.

Upvotes: 3

Related Questions