Skip to content

Instantly share code, notes, and snippets.

@yeoupooh
Created January 7, 2025 01:53
Show Gist options
  • Save yeoupooh/bffe395354ccd72070fa6924dde98bcd to your computer and use it in GitHub Desktop.
Save yeoupooh/bffe395354ccd72070fa6924dde98bcd to your computer and use it in GitHub Desktop.
regular expression in dart
void main() {
final regex = RegExp(r'^[!-~]+$'); // Raw string for the regex
List<String> validStrings = [
r'Hello123!', // Raw string
r'@Flutter_Dart#', // Raw string
r'ABCdef123&*()', // Raw string
r'1234567890', // Raw string
r'!@#$%^&*()', // Raw string
r'~`<>?/|\', // Raw string
r'hello world',
r'',
];
for (var str in validStrings) {
print('$str is valid: ${regex.hasMatch(str)}');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment