Sublime Forum

Find Replace using Regex

#1

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?

0 Likes

#2

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.

0 Likes

#3

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.

0 Likes

#4

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

0 Likes

#5

potentially related:

0 Likes