I get this String from my database:
Test Action Item ZusammenführenTest Action Item ZusammenführenTest Action Item ZusammenführenTest Action Item ZusammenführenTest Action Item ZusammenführenTest Action Item Zusammenführen
fsd
fsa
df
asdf
as
dfs
fd
sad
f
sadf
sad
Now I need to encode all LineBreaks to \n so I can produce proper JSON objects out of the String because JSON doesn't support linebreaks. How can I detect and replace all LineBreaks in the existing String with \n?
I already tried .replace() and replaceAll(). But I need a way to detect the linebreaks First so I can replace them.
Some additional informations:
After trying out several replace-functions mentioned here the JSON still looks like this:
{ "id": 182,
"status": "eing",
"text": "KORE_AI_6",
"beschreibung": "Eins
Zwei
Drei",
"tags": "KORE"
},
And it should look like
{ "id": 182,
"status": "eing",
"text": "KORE_AI_6",
"beschreibung": "Eins\nZwei\nDrei",
"tags": "KORE"
},
\n, what are they?\n? Is the string in your question the actual string you get from the db or something you see with a viewer ?\n, perhaps they are separated by Unicode line separators or paragraph separators. Trys.replaceAll("[\\p{Zl}\\p{Zp}]|\\r?\\n", "\n").