I have the following string:
this is a sample id="aaa bbb ccc" name="abc abc"
I want to match only the whitespace between quotes that start with the string "id=" and replace all occurrences with underscore. The result string should look like:
this is a sample id="aaa_bbb_ccc" name="abc abc"
The following regex matches all whitespace between quotes, but it doesn't take into account the fact that the quotes must be preceded by "id="
\s(?=[^"]*"[^"]*(?:"[^"]*"[^"]*)*$)
Quotes inside quotes are not possible.