Home > Blockchain >  Remove \n from a given strings in dart
Remove \n from a given strings in dart

Time:11-15

Given a string

String item = 'Hello\nWorld'

I want a function that removes \n from the given string
Something like this

String newItem = removeBacklash(item);
print(newItem); // newItem will be 'HelloWorld'

CodePudding user response:

You can use .replaceAll()

String removeBacklash(String data) => data.replaceAll("\n", "");

More about String

  • Related