Hi, I have an editable text box in my UI, when pasted the text there I want to remove all linebreaks from that text, I tried replacing \r \n \t from the string to empty, but nothing happens, tried to get character array and used a for each loop to check if the character is an \r \n or \t but even if that characters appear on the array they aren’t branched. Anyway to solve this?
Works flawless, how I didn’t find that, thank you man s2
I’m running into the same problem but cannot see the solution in this thread. Does anyone know what the solution might be? Thanks.
Try using replace substring. Source is your string you want to remove newlines from. To is just blank, no string goes in there.
For From, hold Shift and press Enter. This will stay in the text field and create a newline. It will look tall, like in the attached image.
This may not work for all strings but between this solution and the \r and \n solution you should cover pretty much everything. It depends on where the string comes from, as different environments may handle new lines in unique ways.
Runtime DataTable : Import and export game data to and from CSV or Google Sheets while your game is running!
easyCSV : Read data from any CSV and put them in an easy-to-access string map!
iTween : Free, smooth, procedural object animation
Thanks @JaredTherriault ! Didn’t think of shift+enter was trying things like \r\n but nothing was working.
Much appreciated!
Ok everyone. I’m still on UE4.25 for a project but this might help someone if the solution above offered by Jared and Clockwork doesn’t work.
See, I’ve been trying all night to detect a newline in a string I KNEW had several. Said string comes from a Text coming from a Data Table where I store my dialogues.
But “Contains”, “Replace”, etc, no node would actually detect a line break.
I finally found a trick that worked in my case every time:
The secret is that a newline (SHIFT+ENTER) has a length of 2. That I knew. What I didn’t know is if you want to detect a newline, then you have to search for the second character and not the first one, somehow.
(Also you can save a node by doing this)
EDIT: ok it gets weirder lol. The aforementioned technique works if the text in the Data Table has NOT been modified manually since the data table was imported.
For a freshly imported data table, you must look for the rightmost character in “ENTER+SHIFT”
But if you have modified manually a text in the editor of the data table and saved it, then you actually have to look for “SHIFT+ENTER”, in this case the normal method by Jared and Clockwork above does work.
So be aware you might need to check for different things depending on your situation. I was maybe facing a weird exception due to how Data Tables work and how they manage to import line breaks from csv files.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.