Last active
February 16, 2021 23:50
-
-
Save johnsogg/72906016a8565b71a4a9c0c7595d1412 to your computer and use it in GitHub Desktop.
Dart Regular Expressions
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
void main() { | |
final pattern = RegExp('^[-\.\' \"’a-zA-Z]+\$'); | |
final inputs = [ | |
"Sting", | |
"John Lennon", | |
"Miles O'Brian", | |
"Miles O’Brian", | |
"Alexandria Ocasio-Cortez", | |
"J.P. Morgan", | |
'Jan "The Man" Jones' | |
]; | |
inputs.forEach((s) { | |
final result = pattern.hasMatch(s); | |
print('${result} ${s}'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment