Created
January 7, 2025 01:53
-
-
Save yeoupooh/bffe395354ccd72070fa6924dde98bcd to your computer and use it in GitHub Desktop.
regular expression in dart
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() { | |
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