tags:

views:

68

answers:

1

I have searched the site for this simple problem but cant find an answer.

I have a multiline string . I want to add a constant string to end of each line. I am using Regex.Replace but facing problems. I tried to replace as the following.

   Pattern             Replace With
-------------------------------------------
    $                   Text
    ($)                 Text$1
    \n                  Text
    \n                  Text\n
    (\n)                Text$1

But none of these work. In all the cases the multiple lines are joined into a single line. How can I accomplish this ?

A: 

You should be able to do:

string newString = oldString.Replace("\r\n", "Text\r\n");

replace Text with the string you want to append to the end of each line

Chief17
I was using Text from a Windows forms TextBox and displaying the result in the textbox.The texbox somehow does not display this correctly- bu the string gets replaced correctly.
josephj1989
From one text box to another it would be:newTB.Text = oldTb.Text.Replace("\r\n", "Text\r\n");Glad I could be of help :o)
Chief17