Find and Replace RegEx
#1

I've never touched RegEx before, as it seems very complicated.

How would I go about, in Sublime Text, replacing occurances of 'Textdraw0', 'Textdraw1', 'Textdraw2' etc. with 'Textdraw[0]', 'Textdraw[1]' and so on? Surely this is one of the most simple things to do with RegEx?
Reply
#2

You can learn and test things out here: http://www.regexr.com/
I reckon this should do it: search for: Textdraw(\d+) and replace with Textdraw[$1]. The \d means digit, the + means "find more" and the brackets create a capture group which is referenced using $1 when replacing.

Edit: you may need to escape the square brackets with a backslash as well. I'm not sure if this is necessary in the replace field.
Reply
#3

Worked beautifully, thanks a lot Vince. Knew it wouldn't be that complicated, but I've never touched RegEx before so it's all new to me. Thanks again.

(P.S. didn't have to escape square brackets in replace field btw)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)