I'm trying to construct a VS22 Find Replace regex expression which will match a specific series of groups on lines of code, and use another expression to update those matching groups.
The lines of code are something like this:
[HttpGet, Route("api/v1/blob"), MyFilter(Keep = "res.Axe, res.Drop")]
[HttpGet, Route("api/v1/blob/{id}/track/{adid}"), MyFilter(Keep = "res.Axe, res.Edit, res.Drop")]
[HttpPut, Route("api/v1/blob/{id}/track/{adid}"), MyFilter(Keep = "res.Axe, res.Edit, res.Build")]
I want to:
- remove the
Keep =
replace all of the,
in the string literals - within the
MyFilter(Keep = ...)
instances
So I've built the best regex expression I can with groups to target the strings which are surrounded by "
or ,
, but preceded by Keep =
...
.*Keep =.*(?<=[",]).*\..*(?=[,"])
However, this appears to be matching the entire row and when I use this replace expression:
"$1 $2"
it replaces each matching row with this:
"$1 $2"")]
How can I modify these expressions to effectively split the string literals found in the MyFilter(Keep = ...)
expressions into a list of strings, going from this example:
MyFilter(Keep = "res.Axe, res.Drop")
to this:
MyFilter("res.Axe", "res.Drop")