I made this line of code
mystring= Regex.Replace(mystring, @"\d+IEME", "E");
But got a problem because I want to keep the number. Like 7IEME
replace to 7E
I made this line of code
mystring= Regex.Replace(mystring, @"\d+IEME", "E");
But got a problem because I want to keep the number. Like 7IEME
replace to 7E
Capture \d+
with a group and then for replacing, use $1
which means "Group 1" followed by E
.
mystring= Regex.Replace(mystring, @"(\d+)IEME", "$1E");
You should be using groups:
string mystring = "7IEME";
mystring= Regex.Replace(mystring, @"(\d+)IEME", "$1E");