Find and Replace RegEx - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Other (
https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (
https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Find and Replace RegEx (
/showthread.php?tid=593490)
Find and Replace RegEx -
MP2 - 06.11.2015
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?
Re: Find and Replace RegEx -
Vince - 06.11.2015
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.
Re: Find and Replace RegEx -
MP2 - 06.11.2015
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)