I have a File, which contains text. Now, I have to replace some string with another. For Example I have to replace
"[ContactLetterSalutation]"
with
"Dear Thomas Kehl".
Now, it is possible, that the placeholder "[ContactLetterSalutation]" contains somewhere "=\r\n" – this could be one, two or more times – for example
"[Conta=\r\ntLetterSa=\r\nlutation]".
I am searching now a way, that I can also replace this – I don’t know where and how many times there will be "=\r\n". The difficult is, that I should not replace all occurrences of "=\r\n" in the text. Can someone help me how to do this? Is there perhaps a possibility to do this with RegEx?
Thank you.
Best Regards, Thomas
edit:
RegexOptions.Singleline causes . to match \n
edit2:
While the above should work for small files, I think this question is more interesting for streams where you couldn’t get the whole file into a single string. I’ve come up with this but it probably has bugs: