PDA

Click to See Complete Forum and Search --> : [RESOLVED] How Can I replace Enter chars in a string


Nitesh
Aug 6th, 2008, 06:12 AM
Hi Guys,

Please show me how to replace enter characters in a string:afrog:

ComputerJy
Aug 6th, 2008, 09:36 AM
String.replace

Nitesh
Aug 7th, 2008, 01:57 AM
Hi ComputerJy,

Thanks. But I need to know what the enter chracter is.Will it be Chr(10) for example.

leinad31
Aug 7th, 2008, 01:58 AM
If its a typical text file then you can use string.replaceAll on the carriage return + line feed combination (use regex). try "\\n" first as the pattern.. if that doesn't work try "\\r" or "\\r\\n"

ComputerJy
Aug 7th, 2008, 02:03 AM
str.replace(System.getProperty("line.separator"), "NewLine");
Where str is a String instance, notice that the line.separator property differs between OSs (\n in unix & \r\n in windows).
You can also use the \n character directly

Nitesh
Aug 7th, 2008, 03:02 AM
thanks a lot guys. That is exactly what I needed:)