I’m using C# replace text in a string but failing when the text is at the end of line.
string filepent = filehex.Replace(",,,,,\r\n", ",EMPTY,EMPTY,EMPTY,EMPTY,EMPTY");
I am loading a txt file into a filestream and then converting to a string. I want to replace a anywhere where it says “,,,,,” at the end of a line. Currently the code above only changes it at the end of the file. At the end of a line where it should change it my hex editor says there is .. or 0D 0A
Thanks
I’d be tempted to instead split the file using File.ReadAllLines, make the replacement, then join them back together. Maybe not the most performant, but clearly expresses your goal. Something like: