Ginzo Milani
Ginzo Milani

Reputation: 418

Regex to capture between two words, and then within that result

I have the following text:

"BOONS": ["Debarrier+Rainbow Shift"
},
"CLUTCH_BOONS": [
  "Boost+Wall"
],

Regex:

(?<=[A-Z a-z])(\+)(?=[A-Z a-z])/g

Using That I am capable of capturing all of the +'s which is great, but I only want to capture the + signs inside of "CLUTCH_BOONS", I have tried really hard with little success.

I also want to close the "BOONS" bracket, I managed to get the left side going properly but cannot get the right quote

(?<=.*)(\")(?=.*\})

end result should look like this

"BOONS": ["Debarrier","Rainbow Shift"]
},
"CLUTCH_BOONS": [
  "Boost","Wall"
],

(I was trying to use Atom / regexr to fix problematic json)

Upvotes: 1

Views: 49

Answers (1)

alsjflalasjf.dev
alsjflalasjf.dev

Reputation: 1689

For the plus signs, you can use this regex:

"\w+": \[\s*"\w+\K\+

see here:

https://regex101.com/r/fJSl37/1

and for the second one:

"(\s*)},

see here:

https://regex101.com/r/Oy0CiJ/1

Upvotes: 1

Related Questions