Created with <3 with dartpad.dev.
Last active
September 12, 2023 15:54
-
-
Save hongsw/956befcec2e7c5804ab9906826942a56 to your computer and use it in GitHub Desktop.
dart string functions
This file contains hidden or 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
void main() { | |
var hello = 'Hello, π!'; | |
print(hello.toUpperCase()); // Output: "HELLO, π!" | |
hello = 'Hello, π!'; | |
print(hello.toLowerCase()); // Output: "hello, π!" | |
hello = ' Hello, π! '; | |
print(hello.trim()); // Output: "Hello, π!" | |
hello = 'Hello, π!'; | |
print(hello.startsWith('Hell')); // Output: true | |
hello = 'Hello, π!'; | |
print(hello.endsWith('π!')); // Output: true | |
hello = 'Hello, π!'; | |
print(hello.contains('lo')); // Output: true | |
hello = 'Hello, π!'; | |
print(hello.substring(0, 5)); // Output: "Hello" | |
hello = 'Hello, π!'; | |
print(hello.replaceFirst('Hello', 'Hi')); // Output: "Hi, π!" | |
hello = 'Hello, Hello, π!'; | |
print(hello.replaceAll('Hello', 'Hi')); // Output: "Hi, Hi, π!" | |
hello = 'Hello, π!'; | |
print(hello.split(', ')); // Output: ['Hello', 'π!'] | |
List<String> helloList = ['Hello', 'π!']; | |
print(helloList.join()); // Output: Helloπ! | |
hello = 'Hello, π!'; | |
print(hello.length); // Output: 11 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment