Reputation: 3001
I need to replace all /
with \
in all matches of the pattern src=""
within a string.
I.e., the pattern starts with src="
and ends with "
There could be multiple matches within the string.
I've tried this but it didn't match:
"src=\"^*\"$"
Upvotes: 0
Views: 93
Reputation: 25593
You can use
String input = @"...src=""/foo/bar""..";
String output = Regex.Replace(input, "src=\"[^\"]*\"", (m) => m.ToString().Replace('/', '\\'));
Upvotes: 1
Reputation: 4585
Does your string always end with the closing " ? If not: remove the $ !
Upvotes: 1