Skip to content

Instantly share code, notes, and snippets.

@johnsogg
Last active February 16, 2021 23:50
Show Gist options
  • Save johnsogg/72906016a8565b71a4a9c0c7595d1412 to your computer and use it in GitHub Desktop.
Save johnsogg/72906016a8565b71a4a9c0c7595d1412 to your computer and use it in GitHub Desktop.
Dart Regular Expressions
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