commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harrie Hazewinkel <har...@inet.it>
Subject escape characters with org.apache.commons.lang.StringUtils
Date Tue, 07 Sep 2004 12:27:01 GMT
HI all,


I would like to replace the substring "\r\n" (consisting of the _4_
characters; '\' 'r' '\' 'n') in a string.
I use the replace method of org.apache.commons.lang.StringUtils,
but I am not sure if I 'escape' it correctly.


For example, string "line1\r\nline2\r\n" should become
"line1=0D=0A=line2=0D=0A=".

This is the oce I am using of the example:

String string = "line1\r\nline2\r\n";
string.indexOf("\\r\\n"); // Return the index of the place found
                           // (and correct!!).
string = StringUtils.replace(string, "\\r\\n", "=0D=0A=");
                           // Does not replace the search string.
                           // result is equal to original.


Now I am wondering whether there is a difference with the escaping
or if I am doing something incorrect.

Does some one has an idea?

hints appreciated,
Harrie








---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message