Created
June 13, 2019 04:58
-
-
Save PlugFox/973fdcaa9f49613ec4b57aaea0a60b5d to your computer and use it in GitHub Desktop.
Title register in dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Title register in dart for https://t.me/rudart | |
* https://gist.github.com/PlugFox/973fdcaa9f49613ec4b57aaea0a60b5d | |
* https://dartpad.dartlang.org/973fdcaa9f49613ec4b57aaea0a60b5d | |
*/ | |
String toTitleRegister(String string) => | |
string | |
.split(RegExp(r'\s')) | |
.map<String>((String val) | |
=> val.isEmpty | |
? '' | |
: '${val[0].toUpperCase()}${val.substring(1).toLowerCase()}') | |
.join(' '); | |
void main() { | |
String data = 'ivan ivan ivan'; | |
print(toTitleRegister(data)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment