I’m looking for a way to go through a string and replace all instances where the second and third characters will always be different but the rest will be the same. For example, if I had:
"ú07ú" to be replaced with "ú07 ú" "ú1Eú" to be replaced with "ú1E ú" "ú12ú" to be replaced with "ú12 ú"
I know I should use Regular Expressions, but they baffle me. I’m pretty sure the syntax will be something like:
Content = Regex.Replace(Content, @"ú...", “ú.. ú");
But obviously this isn’t working. Can any RegEx gurus lend a hand please?
Looks like you want:
Content = Regex.Replace(Content, @"ú([^ú]+)ú", @"ú$1 ú");
Means: match ú, then at least one character that isn't ú (and capture this part), then another ú. If you want it to only match exactly two characters in the middle, then change
Then we replace the whole thing by:
Which is: ú, then the captured part of the string, then a space and ú again.