Skip to content

Commit b246bf7

Browse files
gangaasoonupascalecu
authored andcommitted
Add Remove All Whitespace in Dart (TheRenegadeCoder#4979)
1 parent 8f45775 commit b246bf7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Issue 4973
2+
void main(List<String> argv){
3+
const String error_message = "Usage: please provide a string";
4+
if (argv.isEmpty || argv[0].isEmpty){
5+
print(error_message);
6+
return;
7+
}
8+
//Do not convert \r, \n and \t explicitly into carriage return, newline and tab, as per Jeremy inputs
9+
// Use Regular Expressin to replace carriage return, newline and tab with empty string
10+
String sentence_no_spaces = argv[0].replaceAll(RegExp(r'[\t\r\n ]'), '');
11+
print(sentence_no_spaces);
12+
}

0 commit comments

Comments
 (0)