Android Code Snippet Remove linefeeds & carriagereturn/linefeeds from strings

To remove lenefeeds and carriage return/line feeds from inside strings and replace them with a single space.

    Dim jo As JavaObject = Regex.matcher("[/\r?\n|\r/]", TextToClean)
   Return jo.RunMethod("replaceAll", Array(" "))

It might be straightforward if you're familiar with regular expressions, but it took me a while to find something that worked.


Licensed User
Longtime User
isn't this working aswell without the need for the extra javaobject library?

return Regex.Replace("[/\r?\n|\r/]",TextToClean," "))
Yes, I think you're right. This was probably lazyness on my part. After using the similar code to remove embeded multiple spaces in strings, I eventually ran into a string with multiple CrLF's and my approach to dealing with it must have been 'limited' by my previous thing with the multiple spaces