11,567 questions
I think that you can use two replaces, or:
string sample = "Print Computer information";
string result = Regex.Replace( sample, @"(Print )(.*)( information)", "$1a $2 operation$3" );
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Sample string: "Print Computer information" (Except double quotes)
I want to add "a" after "print" and "operation" before "information".
So the result string is: "Print a Computer operation information"
My regular expression pattern is: @"(Print)(?:.+)(?=information)"
My replacement string is: “$1 a operation”.
But the result is not correct... How to replace it?
I think that you can use two replaces, or:
string sample = "Print Computer information";
string result = Regex.Replace( sample, @"(Print )(.*)( information)", "$1a $2 operation$3" );