commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harrie Hazewinkel <>
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

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,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message