1

How can I call a backreference and immediately follow it by numbers

I'm using the Sublime find&replace RegEx engine (Python) but the problem is the same in PHP:

Example of the problem (obv. neither of these work)

Sublime: Find What: ([a-zA-Z]*)2013 Replace With: $12014

PHP: preg_replace('~([a-zA-Z]*)2013~', '$12014', $file_contents);

Angry Goomba
  • 474
  • 4
  • 20

1 Answers1

1

I found my answer here

Turns out all I had to do was to wrap the back-reference in curly brackets

Solution

Sublime: Find What: ([a-zA-Z]*)2013 Replace With: ${1}2014

PHP: preg_replace('~([a-zA-Z]*)2013~', '${1}2014', $file_contents);

Community
  • 1
  • 1
Angry Goomba
  • 474
  • 4
  • 20