Sublime Forum

REGEX - Search and replace with Increment in multiple files

#1

hello. Suppose I want to number some files. For exemple every file has an “xyz” word.

I want to add a number instead of “xyz”, increment by +1. Some kind of search and replace “xyz” with incremental 1,2,3…etc

“xyz” will become 1 (in first files)
“xyz” will become 2 (in second files)
“xyz” will become 3 (in the third files)

so on

I have a very good php file that can do this, but I don’t know if is in possible in sublime with regex.

0 Likes

#2

No, this kind of thing isn’t what regexes in general can do. It’s not a Sublime Text limitation.

0 Likes

#3

Can do easy in php.

0 Likes

#4

You only asked if it’s possible to do this in sublime with a regex; it’s not. There’s no reason that you could not:

  • create a plugin using python that does it for you
  • create a build system that runs your PHP script to do this for you
2 Likes