Sublime Forum

Find Replace using Regex


Hi all, I am on Build 4113 and am trying to do a RegEx Find and Replace.

I have a json document with multiple lines:
“line 1”: 3
“line 2”: 3
“line 3”: 261
“line 4”: 267
“line 5”: 320

I basically want to change all of the values to 3, and have the following regex (?<=":\s)\d+ in my Find Field, which accurately selects the number values, and I want to replace them all with 3. For some reason when I try this it wraps back to the top and does not let me replace them.

I know that I have done this before with Sublime, I am just not sure why it is not working now… Any thoughts?



I don’t see anything wrong with your regex. I tried your example. If I stepped through with find and replace, it wouldn’t replace the three digit numbers. If I hit replace-all, it worked.



Another approach to your problem would be to search for (“line \d”:\s)\d+ and replace with \13. I tried it on your example and it worked. I still don’t understand why your approach didn’t work.



I tried your search/replace in notepad++ and it worked. I think the problem is with Sublimes regex.



potentially related: