Replacing double quotes with html quote tags for a given string in C# -
Replacing double quotes with html quote tags for a given string in C# -
given c# string like: var str = "this string \"contains\" double quotes.";
i'd transform to: var str = "this string <q>contains</q> double quotes.";
i've got solution loops through , string.replaces double quotes <q> loop through , create every other <q> closing </q> tag. have feeling there's improve way or more understandable way though.
i utilize regex
var str = "this string \"contains\" double \"aaaaa\"quotes."; var str2 = regex.replace(str,@"""(.+?)""", m => "<b>" + m.groups[1].value + "</b>"); c# html string
Comments
Post a Comment