-1

I'm currently retrieving this back

":root{--[{\"name\":\"--font\",\"value\":\"Arial\"},{\"name\":\"--bg\",\"value\":\"black\"}]:;}"

I want this same output but with not backslashes or square brackets.

I've done gsub(/\[/,'') but it's not getting rid of the right square bracket. I know adding a right bracket after the left will mean something totally different with regex.

1 Answers1

-1

You can try this mate

Well as @wiktor mentioned there are no backslashes in your string.Those are backslashes in your string literal.in case you don't have any backslashes [\[\]] this will be enough.

Regex Pattern -> [\[\\\]]


str.gsub(/[\[\\\]]/,'')

Demo

Code Maniac
  • 37,143
  • 5
  • 39
  • 60