Search code examples
regexphpstorm

How to use an altered value of a matched expression as replace value in PhpStorm?


I have some CSV data where I want to de-double quote some numbers.

example data

("string", "34", "some other string"),
("foo", 27, "even more strings!"),
("bar", "11", "one more for luck..")

For which I made this expression:

"[0-9]"

which shows 67 matches. However, I can't figure out how to replace the match with the value without quotes.

I thought of trying \$i but that replaces the "numbers" with a literal $i value.

The PhpStorm regex ref. guide and find and search reference doesn't seem to give much info for non-string related regex replacements so how do I de-double quote values that match a certain pattern ("[0-9]") using CTRL + R in PhpStorm?


Solution

  • Search for: "(\d+)"
    Replace by: $1

    enter image description here

    Use regex capturing groups and backreferences