In my last post and thanks to your help I managed to split the text from a text area into lines and add a "\n" and the end of each line. After that I succesfully updated the field in the database.
So technically the text in the field has been updated to: line1"\n"line2"\n"line3"\n"line4 ( eventhough I don't get to see the "\n" character, I know that it has worked because when I copy-paste the field
directly from the database into a text editor it respects the "\n".
Well, now when I read the string from database and try to apply any of the following methods to the String:
This is usually an escaping problem. The characters you need to escape have to go through two levels of escape: first one for the Java String, and a second for the RegeEx. So try string.split("\\\\n") but maybe string.split("[\\n]") would work as well. How exactly do you add the characters to the string? And how do you know it is or is not working?
Joined: Feb 20, 2013
Hi Steve thank you for replying me!
Look, a field value from the database looks like this:
AV CONSTITUCION RES LOS MANGOS TORRE F PISO 14 TORRE 145F
Adding at the end of each splitted line with line+"\n";
AV CONSTITUCION RES LOS MANGOS
TORRE F PISO 14 TORRE 145F
It actually is stored like this in the database.
And i know it works because I copy-paste the field in a text editor and the "\n" are respected.
My question is
why can't i get to split it into an array of splitted parts?
String ArrayParts = dirOrd.split("[\\n]"); ( with any of the other it doesn't works either)
I'm guessing it could have something to do with the library to retrieve values from the database? sqljdbc4.jar?
Steve Luke wrote:How exactly do you add the characters to the string? And how do you know it is or is not working?
These questions still remain unanswered.
Add to that, what does the string look like when you get it from the DB using your library before you process it?
I believe the "\n" is there, but how - specifically - showing code - do you add it? And how do you know it is not splitting? You show that you do the split. And you say that it does not work. But what does it do, how do you know what it is doing, and how do you prove it is or is not working the way you expect it?
Joined: Feb 20, 2013
Some replacements where applyed to the string after I retrieved it from database.. including one [\\n\\t]
I'm really ashamed with you, because I took part of your time when i simply needed to debug it more carefully.