Sublime Forum

How to partialy replace a mached regex pattern?

#1

I have a file with a lots of numbers like this: “10;23”, “10;24” and also “some text;some text” and I want to replace only the “;” that are between number with “,”. If I put into the “Find what:” field the regex: ;[0-9][0-9] is finding “;24” characters, but I dont know what I need to put into the “Replace with:” to replace ONLY the “;” character and not the numbers. If somebody knows how to do this, please answer.

0 Likes

#2

Just use captures. So for find: “;([0-9]{2})” and then replace: “,$1”.

0 Likes

#3

You can also use positive lookahead assertions: regular-expressions.info/lookaround.html

0 Likes