I am starting to capture RegEx thanks to all the great help here on SO with my other questions. But I still suck this one:
My code is:
StreamReader reader = new StreamReader(fDialog.FileName.ToString());
string content = reader.ReadToEnd();
reader.Close();
I am reading a text file and I want to search for this text and change it (the X and Y values always follow each other in the text file):
X17.8Y-1.
But this text can also be X16.1Y2.3 (the values will always be different after X and Y)
I want to change it to
X17.8Y-1.G54
or
<b> X (value) Y (value) G54
My RegEx instruction follows, but it does not work.
content = Regex.Replace(content, @"(X(?:\d*\.)?\d+)*(Y(?:\d*\.)?\d+)", "$1$2G54");
Can someone change it for me to work and look for X (wildcard) Y (wildcard) and replace it with X (value) Y (value) G54?