Skip to content

Instantly share code, notes, and snippets.

@arnab
Created March 9, 2023 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnab/ffd68dc7bdcbf0a91ec46d13477982ff to your computer and use it in GitHub Desktop.
Save arnab/ffd68dc7bdcbf0a91ec46d13477982ff to your computer and use it in GitHub Desktop.
String extensions Regex tests
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