├── .vscode └── settings.json ├── lib ├── fzregex.dart └── utils │ ├── fzregex.dart │ └── pattern.dart ├── .metadata ├── example └── main.dart ├── pubspec.yaml ├── LICENSE ├── CHANGELOG.md ├── analysis_options.yaml ├── .gitignore └── README.md /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "yaml.schemaStore.enable": false 3 | } -------------------------------------------------------------------------------- /lib/fzregex.dart: -------------------------------------------------------------------------------- 1 | library fzregex; 2 | 3 | export 'utils/fzregex.dart'; 4 | -------------------------------------------------------------------------------- /lib/utils/fzregex.dart: -------------------------------------------------------------------------------- 1 | // ignore: public_member_api_docs 2 | class Fzregex { 3 | /// Returns whether the pattern has a match in the string [input]. 4 | static bool hasMatch(String s, Pattern p) => RegExp(p.toString()).hasMatch(s); 5 | } 6 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: e6b34c2b5c96bb95325269a29a84e83ed8909b5f 8 | channel: beta 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:fzregex/fzregex.dart'; 2 | import 'package:fzregex/utils/pattern.dart'; 3 | 4 | main() { 5 | Fzregex.hasMatch('Krishna_Ra1', FzPattern.username); 6 | Fzregex.hasMatch('+91 7009046544', FzPattern.phone); 7 | Fzregex.hasMatch('krishna@gmail.com', FzPattern.email); 8 | Fzregex.hasMatch('https://youtube.com/', FzPattern.url); 9 | Fzregex.hasMatch('\$ 100,000', FzPattern.currency); 10 | } 11 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: fzregex 2 | description: "A utility package for validating: Phone, Name, PostalCode, Email, URL, Currency, IP Address, Date, Time, HTMLTags, Password (Strong/Medium), and Credit Card. Designed for Dart/Flutter Developers." 3 | version: 2.2.0 4 | homepage: https://github.com/FrazileDevelopers/FzRegex 5 | 6 | environment: 7 | sdk: ">=2.17.0 <4.0.0" # Updated for Dart 2.17+ and Flutter 3.x compatibility 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | dev_dependencies: 14 | flutter_test: 15 | sdk: flutter 16 | lints: ^6.0.0 # Add recommended Dart lints for better code quality 17 | 18 | flutter: 19 | 20 | # assets: 21 | # - images/ 22 | 23 | # fonts: 24 | # - family: Google 25 | # fonts: 26 | # - asset: fonts/google-Regular.ttf 27 | # - asset: fonts/google-Italic.ttf 28 | # style: italic 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020-2024, Frazile Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.2.0 - 10 July 2025. 2 | ### Fixed 3 | - Crypto Currencies Regex added 4 | - Indian TaxIDs Regex added 5 | - US IDs Regex added 6 | - Minor Fixes 7 | 8 | ## 2.1.1 - 27 December 2024. 9 | ### Fixed 10 | - Minor Fixes 11 | 12 | ## 2.1.0 - 27 December 2024. 13 | ### Added 14 | - Compatibility with Dart 2.17+ and Flutter 3.x. 15 | - Added `lints` for improved code quality. 16 | 17 | ### Fixed 18 | - Improved documentation and formatting. 19 | 20 | ### Removed 21 | - Deprecated support for older Dart versions. 22 | 23 | ## 2.0.0 - 10 June 2021. 24 | 25 | _Migrated to null Safety =>_ 26 | 27 | - National Insurance Numbers in UK 28 | 29 | ## 1.0.3 - 22 October 2020. 30 | 31 | _Added New Regex =>_ 32 | 33 | - National Insurance Numbers in UK 34 | - UK post codes 35 | - SSN Number 36 | - US Zip Code 37 | - International Phone Numbers 38 | - Canada Postal Code 39 | 40 | ## 1.0.2 - 23 May 2020. 41 | 42 | - Added New Regex => 43 | - Only Numbers 44 | - Email Regex updated 45 | 46 | ## 1.0.1 - 16 May 2020. 47 | 48 | - Added New Regex & Fixed the Package also. Check Readme & Example for new implementation. 49 | 50 | ## 1.0.0 - 11 May 2020. 51 | 52 | - Added Phone, Name, PostalCode, Email, URL, Currency, IP Address, Date, Time, HTMLTags, Password (Strong), Password (Medium), Credit Card for now. 53 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | analyzer: 2 | exclude: 3 | # Uncomment and specify paths to exclude files or directories from analysis 4 | # - path/to/excluded/files/** 5 | 6 | linter: 7 | rules: 8 | # Best practices 9 | - avoid_print 10 | - cancel_subscriptions 11 | - hash_and_equals 12 | - test_types_in_equals 13 | - unrelated_type_equality_checks 14 | 15 | # Style and conventions 16 | - annotate_overrides 17 | - always_declare_return_types 18 | - always_put_control_body_on_new_line 19 | - always_put_required_named_parameters_first 20 | - avoid_empty_else 21 | - avoid_field_initializers_in_const_classes 22 | - avoid_redundant_argument_values 23 | - avoid_relative_lib_imports 24 | - avoid_setters_without_getters 25 | - camel_case_extensions 26 | - camel_case_types 27 | - constant_identifier_names 28 | - control_flow_in_finally 29 | - empty_constructor_bodies 30 | - library_names 31 | - lines_longer_than_80_chars 32 | - non_constant_identifier_names 33 | - omit_local_variable_types 34 | - prefer_typing_uninitialized_variables 35 | - public_member_api_docs 36 | - require_trailing_commas 37 | - sort_constructors_first 38 | - sort_unnamed_constructors_first 39 | 40 | # Error prevention 41 | - no_adjacent_strings_in_list 42 | - prefer_const_constructors 43 | - prefer_const_literals_to_create_immutables 44 | - provide_deprecation_message 45 | - valid_regexps 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | 77 | # Remove the following pattern if you wish to check in your lock file 78 | pubspec.lock -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FzRegex 2 | 3 | A comprehensive regex validation library for Dart/Flutter developers. Validate formats such as: 4 | 5 | - Phone Numbers 6 | - Names 7 | - Postal Codes 8 | - Emails 9 | - URLs 10 | - IP Addresses 11 | - Dates & Times 12 | - Passwords (Strong & Medium) 13 | - Credit/Debit Cards 14 | - Crypto Validators updated 15 | - And many more! 16 | 17 | [![Pub Version](https://img.shields.io/pub/v/fzregex.svg)](https://pub.dev/packages/fzregex) 18 | [![GitHub Repo](https://img.shields.io/github/stars/FrazileDevelopers/FzRegex.svg?style=social)](https://github.com/FrazileDevelopers/FzRegex) 19 | 20 | --- 21 | 22 | ## 🚀 Installation 23 | 24 | Add the package to the `dependencies:` section of your `pubspec.yaml`: 25 | 26 | ```yaml 27 | dependencies: 28 | fzregex: 29 | ``` 30 | 31 | Then Run 32 | ```sh 33 | flutter pub get 34 | ``` 35 | 36 | ## 🌟 Features 37 | 38 | FzRegex offers validation for a wide range of data formats, including: 39 | 40 | ### 📝 User Input 41 | - Username 42 | - Name 43 | - Only Numbers (Numeric input without whitespace or symbols) 44 | - Passwords (Strong & Medium) 45 | 46 | ### 🖼️ Files & Media 47 | - Images: PNG, JPEG, SVG 48 | - Audio: MP3, WAV, etc. 49 | - Video: MP4, AVI, etc. 50 | - Text Files (TXT) 51 | - Documents: Word (DOC), Excel (XLS), PowerPoint (PPT), PDF 52 | - APK Files 53 | 54 | ### 🔍 Identifiers 55 | - Social Security Numbers (SSN) 56 | - International Standard Book Numbers (ISBN-10 & ISBN-13) 57 | - Passport Numbers 58 | - IP Addresses: IPv4, IPv6 59 | 60 | ### 🌐 Web 61 | - Emails 62 | - URLs 63 | - GitHub Repository Names 64 | - HTML Tags 65 | 66 | ### 💰 Financial 67 | - Credit/Debit Card Numbers 68 | - Currency Formats 69 | - Hash Formats: MD5, SHA1, SHA256 70 | - Crypto Currencies 71 | 72 | ### 🧩 Miscellaneous 73 | - Postal Codes 74 | - Date/Time Validation 75 | - Binary Numbers 76 | 77 | For a detailed list of patterns, visit the [patterns file](https://github.com/FrazileDevelopers/FzRegex/blob/main/lib/utils/pattern.dart). 78 | 79 | ## 🛠️ Usage 80 | 81 | Here’s how you can use FzRegex in your Dart/Flutter project: 82 | 83 | ```dart 84 | import 'package:fzregex/fzregex.dart'; 85 | import 'package:fzregex/utils/pattern.dart'; 86 | 87 | void main() { 88 | // Validate a username 89 | bool isValidUsername = FzRegex.hasMatch('Frazile', FzPattern.username); 90 | 91 | // Validate a phone number 92 | bool isValidPhone = FzRegex.hasMatch('+91 1234567890', FzPattern.phone); 93 | 94 | // Validate an email 95 | bool isValidEmail = FzRegex.hasMatch('frazilex@frazile.app', FzPattern.email); 96 | 97 | // Validate a URL 98 | bool isValidURL = FzRegex.hasMatch('https://frazile.com/', FzPattern.url); 99 | 100 | // Validate currency format 101 | bool isValidCurrency = FzRegex.hasMatch('\$ 100,000', FzPattern.currency); 102 | 103 | print(isValidUsername); // true 104 | print(isValidPhone); // true 105 | } 106 | ``` 107 | 108 | ## ❤️ Support the Project 109 | 110 | If you find this project helpful, consider supporting its development: 111 | 112 | ### Crypto Donations 113 | • Bitcoin (BTC): bc1qfz3nxgnq05zhdfnt7zuzzx9mhmejrm8sv2sfq8 114 | • Ethereum (ETH): 0x27dC4A17C23A22520A395457202CaEae9bFCDAC0 115 | • Tron (TRX): TRrgqPQdFMJ9Lmik2ACKSM3CnnYDDAeYJv 116 | • BNB Smart Chain (BSC): 0x27dC4A17C23A22520A395457202CaEae9bFCDAC0 117 | • Solana (SOL): 98MhEWJ6XQf34cg3vcmh8Ggm7u51bmUvWNKzUQr9MmEt 118 | • Polygon (POL): 0x27dC4A17C23A22520A395457202CaEae9bFCDAC0 119 | • NEAR Token (NEAR): frazile.near 120 | 121 | ## 🧑‍💻 Developed By 122 | 123 | Parth Aggarwal CEO & Developer at Frazile Inc. 124 | 125 | ## 🧑‍💻 Developed By 126 | 127 | **Parth Aggarwal** 128 | CEO & Developer at Frazile Inc. 129 | [GitHub Profile](https://github.com/FrazileDevelopers) 130 | Follow me on [Linkedin Profile](https://www.linkedin.com/in/frazileinc) -------------------------------------------------------------------------------- /lib/utils/pattern.dart: -------------------------------------------------------------------------------- 1 | /// Strict Pattern 2 | /// Symbol ^ and $ in pattern is to make sure all the string value following the pattern 3 | /// Regex will return `false` if any of the characters do not follow the pattern. 4 | /// Example: Email Pattern 5 | /// - testexample.com => `false` 6 | /// - test@example.com => `true` 7 | /// - test@examplecom => `false` 8 | 9 | // ignore_for_file: lines_longer_than_80_chars 10 | 11 | class FzPattern { 12 | /// Username regex 13 | static const Pattern username = r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$'; 14 | 15 | /// Name regex 16 | static const Pattern name = 17 | r"^([A-Z][A-Za-z.'\-]+) (?:([A-Z][A-Za-z.'\-]+) )?([A-Z][A-Za-z.'\-]+)$"; 18 | 19 | /// Email regex 20 | static const Pattern email = 21 | // r'^[a-z0-9]+([-+._][a-z0-9]+){0,2}@.*?(\.(a(?:[cdefgilmnoqrstuwxz]|ero|(?:rp|si)a)|b(?:[abdefghijmnorstvwyz]iz)|c(?:[acdfghiklmnoruvxyz]|at|o(?:m|op))|d[ejkmoz]|e(?:[ceghrstu]|du)|f[ijkmor]|g(?:[abdefghilmnpqrstuwy]|ov)|h[kmnrtu]|i(?:[delmnoqrst]|n(?:fo|t))|j(?:[emop]|obs)|k[eghimnprwyz]|l[abcikrstuvy]|m(?:[acdeghklmnopqrstuvwxyz]|il|obi|useum)|n(?:[acefgilopruz]|ame|et)|o(?:m|rg)|p(?:[aefghklmnrstwy]|ro)|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|t(?:[cdfghjklmnoprtvwz]|(?:rav)?el)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])\b){1,2}$'; 22 | r"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$"; 23 | 24 | /// URL regex 25 | static const Pattern url = 26 | r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"; 27 | 28 | /// Phone Number regex 29 | /// Must started by either, "0", "+", "+XX ", "(+XX )" 30 | /// Can add whitespace separating digit with "+" or "(+XX)" 31 | /// Example: 05555555555, +555 5555555555, (+123) 5555555555, (555) 5555555555, +5555 5555555555 32 | static const Pattern phone = 33 | r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$'; 34 | 35 | /// Hexadecimal regex 36 | static const Pattern hexadecimal = r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'; 37 | 38 | /// Image vector regex 39 | static const Pattern vector = r'.(svg)$'; 40 | 41 | /// Image regex 42 | static const Pattern image = r'.(jpeg|jpg|gif|png|bmp)$'; 43 | 44 | /// Audio regex 45 | static const Pattern audio = r'.(mp3|wav|wma|amr|ogg)$'; 46 | 47 | /// Video regex 48 | static const Pattern video = r'.(mp4|avi|wmv|rmvb|mpg|mpeg|3gp)$'; 49 | 50 | /// Txt regex 51 | static const Pattern txt = r'.txt$'; 52 | 53 | /// Document regex 54 | static const Pattern doc = r'.(doc|docx)$'; 55 | 56 | /// Excel regex 57 | static const Pattern excel = r'.(xls|xlsx)$'; 58 | 59 | /// PPT regex 60 | static const Pattern ppt = r'.(ppt|pptx)$'; 61 | 62 | /// APK regex 63 | static const Pattern apk = r'.apk$'; 64 | 65 | /// PDF regex 66 | static const Pattern pdf = r'.pdf$'; 67 | 68 | /// HTML regex 69 | static const Pattern html = r'.html$'; 70 | 71 | /// DateTime regex (UTC) 72 | /// Unformatted date time (UTC and Iso8601) 73 | /// Example: 2020-04-27 08:14:39.977, 2020-04-27T08:14:39.977, 2020-04-27 01:14:39.977Z 74 | static const Pattern basicDateTime = 75 | r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$'; 76 | 77 | /// Binary regex 78 | /// Consist only 0 & 1 79 | static const Pattern binary = r'^[0-1]*$'; 80 | 81 | /// MD5 regex 82 | static const Pattern md5 = r'^[a-f0-9]{32}$'; 83 | 84 | /// SHA1 regex 85 | static const Pattern sha1 = 86 | r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})'; 87 | 88 | /// SHA256 regex 89 | static const Pattern sha256 = 90 | r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}'; 91 | 92 | /// SSN (Social Security Number) regex 93 | static const Pattern ssn = 94 | r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'; 95 | 96 | /// IPv4 regex 97 | static const Pattern ipv4 = 98 | r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$'; 99 | 100 | /// IPv6 regex 101 | static const Pattern ipv6 = 102 | r'^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$'; 103 | 104 | /// ISBN 10 & 13 regex 105 | static const Pattern isbn = 106 | r'(ISBN(\-1[03])?[:]?[ ]?)?(([0-9Xx][- ]?){13}|([0-9Xx][- ]?){10})'; 107 | 108 | /// Github repository regex 109 | static const Pattern github = 110 | r'((git|ssh|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:/\-~]+)(\.git)(\/)?'; 111 | 112 | /// Passport No. regex 113 | static const Pattern passport = r'^(?!^0+$)[a-zA-Z0-9]{6,9}$'; 114 | 115 | /// Currency regex 116 | static const Pattern currency = 117 | r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$'; 118 | 119 | /// Numeric Only regex (No Whitespace & Symbols) 120 | static const Pattern numericOnly = r'^\d+$'; 121 | 122 | /// Alphabet Only regex (No Whitespace & Symbols) 123 | static const Pattern alphabetOnly = r'^[a-zA-Z]+$'; 124 | 125 | /// Password (Easy) Regex 126 | /// Allowing all character except 'whitespace' 127 | /// Minimum character: 8 128 | static const Pattern passwordEasy = r'^\S{8,}$'; 129 | 130 | /// Password (Easy) Regex 131 | /// Allowing all character 132 | /// Minimum character: 8 133 | static const Pattern passwordEasyAllowedWhitespace = r'^[\S ]{8,}$'; 134 | 135 | /// Password (Normal) Regex 136 | /// Allowing all character except 'whitespace' 137 | /// Must contains at least: 1 letter & 1 number 138 | /// Minimum character: 8 139 | static const Pattern passwordNormal1 = r'^(?=.*[A-Za-z])(?=.*\d)\S{8,}$'; 140 | 141 | /// Password (Normal) Regex 142 | /// Allowing all character 143 | /// Must contains at least: 1 letter & 1 number 144 | /// Minimum character: 8 145 | static const Pattern passwordNormal1AllowedWhitespace = 146 | r'^(?=.*[A-Za-z])(?=.*\d)[\S ]{8,}$'; 147 | 148 | /// Password (Normal) Regex 149 | /// Allowing LETTER and NUMBER only 150 | /// Must contains at least: 1 letter & 1 number 151 | /// Minimum character: 8 152 | static const Pattern passwordNormal2 = 153 | r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9]{8,}$'; 154 | 155 | /// Password (Normal) Regex 156 | /// Allowing LETTER and NUMBER only 157 | /// Must contains: 1 letter & 1 number 158 | /// Minimum character: 8 159 | static const Pattern passwordNormal2AllowedWhitespace = 160 | r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9 ]{8,}$'; 161 | 162 | /// Password (Normal) Regex 163 | /// Allowing all character except 'whitespace' 164 | /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number 165 | /// Minimum character: 8 166 | static const Pattern passwordNormal3 = 167 | r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)\S{8,}$'; 168 | 169 | /// Password (Normal) Regex 170 | /// Allowing all character 171 | /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number 172 | /// Minimum character: 8 173 | static const Pattern passwordNormal3AllowedWhitespace = 174 | r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\S ]{8,}$'; 175 | 176 | /// Password (Hard) Regex 177 | /// Allowing all character except 'whitespace' 178 | /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol) 179 | /// Minimum character: 8 180 | static const Pattern passwordHard = 181 | r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])\S{8,}$'; 182 | 183 | /// Password (Hard) Regex 184 | /// Allowing all character 185 | /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol) 186 | /// Minimum character: 8 187 | static const Pattern passwordHardAllowedWhitespace = 188 | r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[\S ]{8,}$'; 189 | 190 | /// Postal Code 191 | static const Pattern postalCode = r"^\d{5}(-\d{4})?$"; 192 | 193 | /// HTML Tags 194 | /// multiLine = true 195 | static const Pattern htmlTags = 196 | r"^<(?:([A-Za-z][A-Za-z0-9]*)\b[^>]*>(?:.*?)|[A-Za-z][A-Za-z0-9]*\b[^/>]*/>)$"; 197 | 198 | /// Credit/Debit Card 199 | static const Pattern creditcard = 200 | r"^(?:3[47]\d{2}([\- ]?)\d{6}\1\d{5}|(?:4\d{3}|5[1-5]\d{2}|6011)([\- ]?)\d{4}\2\d{4}\2\d{4})$"; 201 | 202 | /// Only Numbers 203 | static const Pattern onlynumber = r'^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$'; 204 | 205 | /// Matches national insurance numbers in the UK 206 | static final RegExp ninValidator = 207 | RegExp(r"^\s*[a-zA-Z]{2}(?:\s*\d\s*){6}[a-zA-Z]?\s*$"); 208 | 209 | /// Matches UK post codes 210 | static final RegExp postCodeValidator = RegExp( 211 | r"([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})"); 212 | 213 | /// Matches SSN Number 214 | static final RegExp ssnValidator = 215 | RegExp(r"^(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}$"); 216 | 217 | /// Matches US Zip Code Validation 218 | static final RegExp uszipcodeValidator = RegExp(r"^[0-9]{5}(?:-[0-9]{4})?$"); 219 | 220 | /// Matches International Phone Numbers 221 | static final RegExp internationalPhoneNumValidator = 222 | RegExp(r"^\+(?:[0-9] ?){6,14}[0-9]$"); 223 | 224 | /// Matches Canada Postal Code Validation 225 | static final RegExp canadaPostalCodeValidator = 226 | RegExp(r"^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$"); 227 | 228 | /// YouTube Video URL Regex 229 | /// Examples: https://youtu.be/dQw4w9WgXcQ, https://www.youtube.com/watch?v=dQw4w9WgXcQ 230 | static const Pattern youtubeUrl = 231 | r'^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+$'; 232 | 233 | /// MAC Address Regex 234 | /// Examples: 00:1A:2B:3C:4D:5E, 00-1A-2B-3C-4D-5E 235 | static const Pattern macAddress = 236 | r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'; 237 | 238 | /// Time (24-hour format) Regex 239 | /// Examples: 23:59, 00:00, 14:30 240 | static const Pattern time24 = r'^([01]\d|2[0-3]):([0-5]\d)$'; 241 | 242 | /// Time (12-hour format with AM/PM) Regex 243 | /// Examples: 1:45 PM, 12:00 am, 09:15 Am 244 | static const Pattern time12 = 245 | r'^(0?[1-9]|1[0-2]):[0-5][0-9](\s)?(?i)(AM|PM)$'; 246 | 247 | /// Color Code (Hex with optional alpha) Regex 248 | /// Examples: #FFF, #FFFFFF, #FFFFFFFF, #1234 249 | static const Pattern colorHexWithAlpha = 250 | r'^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$'; 251 | 252 | /// Twitter Username Regex 253 | /// Examples: @username, username 254 | static const Pattern twitterUsername = r'^@?(\w){1,15}$'; 255 | 256 | /// UUID v4 Regex 257 | /// Example: f47ac10b-58cc-4372-a567-0e02b2c3d479 258 | static const Pattern uuidV4 = 259 | r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'; 260 | 261 | /// Slug (URL-friendly string) Regex 262 | /// Examples: hello-world, flutter-tutorial, my-blog-post 263 | static const Pattern slug = r'^[a-z0-9]+(?:-[a-z0-9]+)*$'; 264 | 265 | /// Firebase Push ID Regex 266 | /// Example: -MabcdEfghIJKlmNoPqR 267 | static const Pattern firebasePushId = r'^[a-zA-Z0-9_-]{20}$'; 268 | 269 | /// Emoji Regex (basic support for common emojis) 270 | /// Examples: 😀, ❤️, 🚀 271 | static const Pattern emoji = r'(\p{Emoji_Presentation}|\p{Emoji}\uFE0F)'; 272 | 273 | /// IPv4 CIDR Notation Regex 274 | /// Examples: 192.168.1.0/24, 10.0.0.0/8 275 | static const Pattern ipv4Cidr = 276 | r'^(([0-9]{1,3}\.){3}[0-9]{1,3})\/([0-9]|[1-2][0-9]|3[0-2])$'; 277 | 278 | /// Base64 String Regex 279 | /// Examples: SGVsbG8gd29ybGQ=, U29tZSBzdHJpbmc= 280 | static const Pattern base64 = 281 | r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$'; 282 | 283 | /// Bitcoin Address Regex (Legacy & SegWit) 284 | /// Examples: 1BoatSLRHtKNngkdXEeobR76b53LETtpyT, 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy 285 | static const Pattern bitcoinAddress = r'^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$'; 286 | 287 | /// Ethereum Address Regex 288 | /// Examples: 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe 289 | static const Pattern ethereumAddress = r'^0x[a-fA-F0-9]{40}$'; 290 | 291 | /// Litecoin Address Regex 292 | /// Examples: LZym3j8fS9bWf8o6RzKvA3tC2AedZ6W9aW 293 | static const Pattern litecoinAddress = r'^[LM3][a-km-zA-HJ-NP-Z1-9]{26,33}$'; 294 | 295 | /// Ripple (XRP) Address Regex 296 | /// Examples: rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn 297 | static const Pattern rippleAddress = r'^r[0-9a-zA-Z]{24,34}$'; 298 | 299 | /// Dogecoin Address Regex 300 | /// Examples: D5r2hrU1qJUzS9NBpZxkA6sZs6kKjA3vZc 301 | static const Pattern dogecoinAddress = r'^[D9A][a-km-zA-HJ-NP-Z1-9]{25,34}$'; 302 | 303 | /// Monero Address Regex 304 | /// Examples: 48bWuoDGAGY4o9c8ZC2XG3dQtrM7StJmqAsYHgw4x9qV6uW6t7P1AJVC3fUQ7m7G3yyMfA8GJmLt4zHYvstDQCQL6j9e9sS 305 | static const Pattern moneroAddress = r'^[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}$'; 306 | 307 | /// Dash Address Regex 308 | /// Examples: XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg 309 | static const Pattern dashAddress = r'^X[1-9A-HJ-NP-Za-km-z]{33}$'; 310 | 311 | /// Cardano Shelley Address Regex (starts with addr1) 312 | /// Examples: addr1q9z06azdku5f8u20szctwegrv08c7l5psxx4c83n0nq3qkdjqw7zzg8v4ga2q9q8rpgz2c6x0nnpag6t0jx9cq4tgf6qg0ahz3 313 | static const Pattern cardanoAddress = r'^addr1[0-9a-z]{58,}$'; 314 | 315 | /// Solana Address Regex 316 | /// Examples: 4Nd1mYzGQj6PPZQZn5hVQ5AYy6AS2FoKZ5FBL2XRxYcB 317 | static const Pattern solanaAddress = r'^[1-9A-HJ-NP-Za-km-z]{32,44}$'; 318 | 319 | /// Polkadot Address Regex 320 | /// Examples: 12D3KooWM1rCZU4vT2LuXoYgB1T6PqvpmGJv8SBrC7oQQXvQUgZq 321 | static const Pattern polkadotAddress = r'^[1-9A-HJ-NP-Za-km-z]{47,48}$'; 322 | 323 | /// Tron Address Regex 324 | /// Examples: TQ5xAinUM2BV5EUD5L5EwbBeH6RBaJv1io 325 | static const Pattern tronAddress = r'^T[1-9A-HJ-NP-Za-km-z]{33}$'; 326 | 327 | /// Binance Chain (BEP-20) Address Regex (Same as Ethereum) 328 | /// Examples: 0x28C6c06298d514Db089934071355E5743bf21d60 329 | static const Pattern binanceSmartChainAddress = r'^0x[a-fA-F0-9]{40}$'; 330 | 331 | /// Private Key (Ethereum-like 64 hex chars) 332 | /// Examples: 4c0883a69102937d6231471b5dbb6204fe51296170827946d27b382e66ad4f4f 333 | static const Pattern privateKeyHex = r'^[a-fA-F0-9]{64}$'; 334 | 335 | /// Transaction Hash (64 hex characters) 336 | /// Examples: 0x5e2d3c57c0e58923a948e8cd5a1a8d5f50f5a5caa1bcf7d8a1de474f21f7915a 337 | static const Pattern transactionHash = r'^0x([A-Fa-f0-9]{64})$'; 338 | 339 | /// BIP39 Mnemonic Regex (12 or 24 words) 340 | /// Examples: 341 | /// legal winner thank year wave sausage worth useful legal winner thank yellow 342 | /// abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about 343 | static const Pattern bip39Mnemonic = 344 | r'^([a-z]+ ){11}[a-z]+$|^([a-z]+ ){23}[a-z]+$'; 345 | 346 | /// GSTIN (Goods and Services Tax Identification Number) - 15 characters 347 | /// Format: 2 digit state code + 10-digit PAN + 1 entity code + 1 checksum 348 | /// Example: 22AAAAA0000A1Z5 349 | static const Pattern gstin = 350 | r'^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$'; 351 | 352 | /// PAN (Permanent Account Number) - 10 characters 353 | /// Format: 5 letters + 4 digits + 1 letter 354 | /// Example: ABCDE1234F 355 | static const Pattern pan = r'^[A-Z]{5}[0-9]{4}[A-Z]$'; 356 | 357 | /// Aadhaar (UIDAI 12-digit number) 358 | /// Format: 12 digits, cannot start with 0 or 1 359 | /// Example: 234567890123 360 | static const Pattern aadhaar = r'^[2-9]{1}[0-9]{11}$'; 361 | 362 | /// IBAN (International Bank Account Number) 363 | /// Supports general IBAN structure: 2 letters country code + 2 digits + up to 30 alphanumeric chars 364 | /// Example: GB82WEST12345698765432 365 | static const Pattern iban = r'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$'; 366 | 367 | /// US SSN (Social Security Number) - Strict format: XXX-XX-XXXX 368 | /// Invalid prefixes like 000, 666, and 900–999 are not allowed 369 | /// Example: 123-45-6789 370 | static const Pattern usSsnStrict = 371 | r'^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$'; 372 | 373 | /// IFSC Code - 11 characters 374 | /// Format: 4 letters (bank code) + 0 + 6-digit branch code 375 | /// Example: SBIN0005943 376 | static const Pattern ifsc = r'^[A-Z]{4}0[A-Z0-9]{6}$'; 377 | 378 | /// UPI ID Regex (e.g. mobile@upi or username@bank) 379 | /// Accepts lowercase, digits, dot, dash, plus underscore in name; domain must be alphanumeric 380 | /// Examples: test.user@okaxis, 1234567890@upi 381 | static const Pattern upiId = r'^[a-z0-9.\-_+]{2,256}@[a-z]{2,64}$'; 382 | } 383 | --------------------------------------------------------------------------------