K
Krish
Hi,
In our application we need to replace the text \n to \r\n, but few of
our text has \r\n. I am not sure how to handle the case.
for eg; Test\rOneMore\r\n.
I need the output has Test\r\nOneMore\r\n.
I know I can do this using String.Replace method... but I need to use
Regex.
I tried using
String str = "Test\nOneMore\r\n";
Regex rx = new Regex("[^\r]\n",RegexOptions.IgnoreCase |
RegexOptions.Compiled);
str = rx.replace(str, "\r\n");
Output:
Tes\r\nOneMore\r\n. ** "t" from test is missing. I think it is
expected behaviour"
Anyhelp is appreciated.
Thanks,
Krish
In our application we need to replace the text \n to \r\n, but few of
our text has \r\n. I am not sure how to handle the case.
for eg; Test\rOneMore\r\n.
I need the output has Test\r\nOneMore\r\n.
I know I can do this using String.Replace method... but I need to use
Regex.
I tried using
String str = "Test\nOneMore\r\n";
Regex rx = new Regex("[^\r]\n",RegexOptions.IgnoreCase |
RegexOptions.Compiled);
str = rx.replace(str, "\r\n");
Output:
Tes\r\nOneMore\r\n. ** "t" from test is missing. I think it is
expected behaviour"
Anyhelp is appreciated.
Thanks,
Krish