Home > Back-end >  Regex: match, but do not include in groups
Regex: match, but do not include in groups

Time:10-21

I have some objects like this:

"unit":{
          "id":"1",
          "title":"I am a title",
          "description":" description",
          "category":{
            "name":"Reading",
            "type":"READING",
            "icon":"fas fa-book"
}

I'd like to remove the double quotes from the keys. Is there a good way to do this in regex? I use: ".*": to match the key's, but am unsure of how to do the partial replace in VSCode. I tried this solution, but was unsuccessful.

CodePudding user response:

You can use

"([^"] )":

Replace with $1:. Details:

  • " - a double quote
  • ([^"] ) - Group 1 ($1 refers to the this group value): any one or more chars other than "
  • ": - a ": string.
  • Related