The first way of
import Java.util.regex.Pattern;
Import Java.util.regex.Matcher;
...
4 different combinaisons pattern
CRLF = Pattern.compile ("(\r\n|\r|\n|\n\r)");
Matcher m = Crlf.matcher (myString);
if (M.find ()) {
newstring = M.replaceall ("<br>");
}
The second way
newstring = Mystring.replaceall ("(\r\n|\r|\n|\n\r)", "<br>");
Test
Import Java.util.regex.Matcher;
Import Java.util.regex.Pattern;
public class Stringtest {public
static string sss (String myString) {
string newstring=null;
Pattern CRLF = Pattern.compile ("(\r\n|\r|\n|\n\r)");
Matcher m = Crlf.matcher (myString);
if (M.find ()) {
newstring = M.replaceall ("<br>");
}
return newstring;
}
/**
* @param args
*
/public static void main (string[] args) {
String aaa= "sdfsfdsfsdf\r\n, Dsfsdfsdf\r\n ";
Aaa.replace ("S", "X");
String newstr=sss (AAA);
System.out.println (NEWSTR);
}