Created
March 9, 2023 20:31
-
-
Save arnab/ffd68dc7bdcbf0a91ec46d13477982ff to your computer and use it in GitHub Desktop.
String extensions Regex tests
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() { | |
print("Foo.".endsWithPeriod()); | |
print("foo. ".endsWithPeriod()); | |
print(" foo. ".endsWithPeriod()); | |
print("foo. Abc".endsWithPeriod()); | |
print("Abc".endsWithPeriod()); | |
print("".endsWithPeriod()); | |
} | |
extension StringExtension on String { | |
bool endsWithPeriod() => contains(RegExp("\\.\\s*\$")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment