1

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

1

2 Answers 2

6

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"); 
Sign up to request clarification or add additional context in comments.

Comments

0

You should be using groups:

string mystring = "7IEME";
mystring= Regex.Replace(mystring, @"(\d+)IEME", "$1E"); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.