Are you
sure it is \n\r? Normally in Windows the end of line character sequence is the other way around (i.e., \r\n).
Also, 4 of the examples you've shown have the wrong slashes (i.e., you have
/n/r
where you should use
\n\r
).
You do
not want the
@
prefix to the strings as that makes the slash characters regular characters instead of parts of escaped character sequences.
Assuming the original string is as shown, try:
string currentNodeSourceText = "MOVE 'S0500' TO CDA-ERROR-TAG-DATA(CDA-LEVEL-INDEX).\n\rMOVE FND-ERROR-BLOCK TO SAVE-FND-ERROR-BLOCK.\n\rMOVE 'S0500-HOUSEKEEPING' TO FND-ERROR-TAG-DATA.\n\rMOVE LT-PROGRAM-NAME TO FND-PGM-ID.\n\rSET FND-APPL-TYPE-UTILITY TO TRUE.\n\rSET FND-ERROR-TYPE-USER TO TRUE.\n\rMOVE LT-PROGRAM-NAME TO CDA-PROGRAM-ID(CDA-LEVEL-INDEX).";
string newText = currentNodeSourceText.Replace("\n\r", "^");
The
Regex
is overkill for this substitution. (And remember that the
Replace
does NOT modify the input string, it returns a new string, so be sure to save the result.)