Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jonatas
2020-08-26 14:10:17 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
892b7504642acd1174a4153283c5b140ec0edf76
892b7504
1 parent
3a1dccc5
remove accidental code on GetUtils of other lib
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
264 deletions
benchmark/state_managers/pubspec.lock
lib/src/state_manager/rx/rx_obx.dart
lib/src/utils/extensions/string_extensions.dart
lib/src/utils/regex/get_utils.dart
lib/src/utils/regex/get_utils_extensions.dart
lib/src/utils/regex/regex.dart
benchmark/state_managers/pubspec.lock
View file @
892b750
...
...
@@ -15,13 +15,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.10"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
...
...
@@ -277,13 +270,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
io:
dependency: transitive
description:
...
...
@@ -389,13 +375,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
pool:
dependency: transitive
description:
...
...
@@ -562,13 +541,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
yaml:
dependency: transitive
description:
...
...
lib/src/state_manager/rx/rx_obx.dart
View file @
892b750
import
'dart:async'
;
import
'package:flutter/widgets.dart'
;
import
'package:get/src/state_manager/rx/rx_interface.dart'
;
import
'rx_impl.dart'
;
Widget
obx
(
Widget
Function
()
builder
)
{
...
...
@@ -96,7 +94,7 @@ class _ObxState extends State<Obx> {
/// false.obs,
/// ),
// TODO: change T to a proper Rx interfa
s
e, that includes the accessor for ::value
// TODO: change T to a proper Rx interfa
c
e, that includes the accessor for ::value
class
ObxValue
<
T
extends
RxInterface
>
extends
StatefulWidget
{
final
Widget
Function
(
T
)
builder
;
final
T
data
;
...
...
lib/src/utils/extensions/string_extensions.dart
View file @
892b750
...
...
@@ -10,7 +10,7 @@ extension GetStringUtils on String {
bool
get
isAudioFileName
=>
GetUtils
.
isAudio
(
this
);
bool
get
isVideoFileName
=>
GetUtils
.
isVideo
(
this
);
bool
get
isTxtFileName
=>
GetUtils
.
isTxt
(
this
);
bool
get
isDocumentFileName
=>
GetUtils
.
is
Document
(
this
);
bool
get
isDocumentFileName
=>
GetUtils
.
is
Word
(
this
);
bool
get
isExcelFileName
=>
GetUtils
.
isExcel
(
this
);
bool
get
isPPTFileName
=>
GetUtils
.
isPPT
(
this
);
bool
get
isAPKFileName
=>
GetUtils
.
isAPK
(
this
);
...
...
@@ -23,7 +23,6 @@ extension GetStringUtils on String {
bool
get
isMD5
=>
GetUtils
.
isMD5
(
this
);
bool
get
isSHA1
=>
GetUtils
.
isSHA1
(
this
);
bool
get
isSHA256
=>
GetUtils
.
isSHA256
(
this
);
bool
get
isISBN
=>
GetUtils
.
isISBN
(
this
);
bool
get
isBinary
=>
GetUtils
.
isBinary
(
this
);
bool
get
isIPv4
=>
GetUtils
.
isIPv4
(
this
);
bool
get
isIPv6
=>
GetUtils
.
isIPv6
(
this
);
...
...
lib/src/utils/regex/get_utils.dart
View file @
892b750
import
'package:get/src/utils/regex/regex.dart'
;
class
GetUtils
{
/// Checks if data is null.
static
bool
isNull
(
dynamic
s
)
=>
s
==
null
;
...
...
@@ -28,12 +26,10 @@ class GetUtils {
/// Checks if string consist only numeric.
/// Numeric only doesn't accepting "." which double data type have
static
bool
isNumericOnly
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
numericOnly
);
static
bool
isNumericOnly
(
String
s
)
=>
hasMatch
(
s
,
r'^\d+$'
);
/// Checks if string consist only Alphabet. (No Whitespace)
static
bool
isAlphabetOnly
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
alphabetOnly
);
static
bool
isAlphabetOnly
(
String
s
)
=>
hasMatch
(
s
,
r'^[a-zA-Z]+$'
);
/// Checks if string is boolean.
static
bool
isBool
(
String
s
)
{
...
...
@@ -41,81 +37,133 @@ class GetUtils {
return
(
s
==
'true'
||
s
==
'false'
);
}
/// Checks if string is an vector file.
static
bool
isVector
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
vector
);
/// Checks if string is an video file.
static
bool
isVideo
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
(((((
ext
.
endsWith
(
".mp4"
)
||
ext
.
endsWith
(
".avi"
))
||
ext
.
endsWith
(
".wmv"
))
||
ext
.
endsWith
(
".rmvb"
))
||
ext
.
endsWith
(
".mpg"
))
||
ext
.
endsWith
(
".mpeg"
))
||
ext
.
endsWith
(
".3gp"
);
}
/// Checks if string is an image file.
static
bool
isImage
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
image
);
static
bool
isImage
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
(((
ext
.
endsWith
(
".jpg"
)
||
ext
.
endsWith
(
".jpeg"
))
||
ext
.
endsWith
(
".png"
))
||
ext
.
endsWith
(
".gif"
))
||
ext
.
endsWith
(
".bmp"
);
}
/// Checks if string is an audio file.
static
bool
isAudio
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
audio
);
static
bool
isAudio
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
(((
ext
.
endsWith
(
".mp3"
)
||
ext
.
endsWith
(
".wav"
))
||
ext
.
endsWith
(
".wma"
))
||
ext
.
endsWith
(
".amr"
))
||
ext
.
endsWith
(
".ogg"
);
}
/// Checks if string is an video file.
static
bool
isVideo
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
video
);
/// Checks if string is an powerpoint file.
static
bool
isPPT
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
ext
.
endsWith
(
".ppt"
)
||
ext
.
endsWith
(
".pptx"
);
}
/// Checks if string is an txt file.
static
bool
isTxt
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
txt
);
/// Checks if string is an word file.
static
bool
isWord
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
ext
.
endsWith
(
".doc"
)
||
ext
.
endsWith
(
".docx"
);
}
/// Checks if string is an Doc file.
static
bool
isDocument
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
doc
);
/// Checks if string is an excel file.
static
bool
isExcel
(
String
filePath
)
{
String
ext
=
filePath
.
toLowerCase
();
return
ext
.
endsWith
(
".xls"
)
||
ext
.
endsWith
(
".xlsx"
);
}
/// Checks if string is an Excel file.
static
bool
isExcel
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
excel
);
/// Checks if string is an apk file.
static
bool
isAPK
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".apk"
);
}
/// Checks if string is an PPT file.
static
bool
isPPT
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
ppt
);
/// Checks if string is an pdf file.
static
bool
isPDF
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".pdf"
);
}
/// Checks if string is an APK file.
static
bool
isAPK
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
apk
);
/// Checks if string is an txt file.
static
bool
isTxt
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".txt"
);
}
/// Checks if string is an video file.
static
bool
isPDF
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
pdf
);
/// Checks if string is an chm file.
static
bool
isChm
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".chm"
);
}
/// Checks if string is an HTML file.
static
bool
isHTML
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
html
);
/// Checks if string is a vector file.
static
bool
isVector
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".svg"
);
}
/// Checks if string is an html file.
static
bool
isHTML
(
String
filePath
)
{
return
filePath
.
toLowerCase
().
endsWith
(
".html"
);
}
/// Checks if string is a valid username.
static
bool
isUsername
(
String
s
)
=>
hasMatch
(
s
,
r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$'
);
/// Checks if string is URL.
static
bool
isURL
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
url
);
static
bool
isURL
(
String
s
)
=>
hasMatch
(
s
,
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\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"
);
/// Checks if string is email.
static
bool
isEmail
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
email
);
static
bool
isEmail
(
String
s
)
=>
hasMatch
(
s
,
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'
);
/// Checks if string is phone number.
static
bool
isPhoneNumber
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
phone
);
static
bool
isPhoneNumber
(
String
s
)
=>
hasMatch
(
s
,
r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$'
);
/// Checks if string is DateTime (UTC or Iso8601).
static
bool
isDateTime
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
basicDateTime
);
hasMatch
(
s
,
r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$'
);
/// Checks if string is MD5 hash.
static
bool
isMD5
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
md5
);
static
bool
isMD5
(
String
s
)
=>
hasMatch
(
s
,
r'^[a-f0-9]{32}$'
);
/// Checks if string is SHA1 hash.
static
bool
isSHA1
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
sha1
);
static
bool
isSHA1
(
String
s
)
=>
hasMatch
(
s
,
r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})'
);
/// Checks if string is SHA256 hash.
static
bool
isSHA256
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
sha256
);
/// Checks if string is ISBN 10 or 13.
static
bool
isISBN
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
isbn
);
static
bool
isSHA256
(
String
s
)
=>
hasMatch
(
s
,
r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}'
);
/// Checks if string is SSN (Social Security Number).
static
bool
isSSN
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
ssn
);
static
bool
isSSN
(
String
s
)
=>
hasMatch
(
s
,
r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'
);
/// Checks if string is binary.
static
bool
isBinary
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
binary
);
static
bool
isBinary
(
String
s
)
=>
hasMatch
(
s
,
r'^[0-1]*$'
);
/// Checks if string is IPv4.
static
bool
isIPv4
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
ipv4
);
static
bool
isIPv4
(
String
s
)
=>
hasMatch
(
s
,
r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$'
);
/// Checks if string is IPv6.
static
bool
isIPv6
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
ipv6
);
static
bool
isIPv6
(
String
s
)
=>
hasMatch
(
s
,
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}:))$'
);
/// Checks if string is hexadecimal.
/// Example: HexColor => #12F
static
bool
isHexadecimal
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
hexadecimal
);
hasMatch
(
s
,
r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'
);
/// Checks if string is Palindrom.
static
bool
isPalindrom
(
String
s
)
{
...
...
@@ -151,11 +199,11 @@ class GetUtils {
/// Checks if string is Passport No.
static
bool
isPassport
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
passport
);
hasMatch
(
s
,
r'^(?!^0+$)[a-zA-Z0-9]{6,9}$'
);
/// Checks if string is Currency.
static
bool
isCurrency
(
String
s
)
=>
RegexValidation
.
hasMatch
(
s
,
regex
.
currency
);
static
bool
isCurrency
(
String
s
)
=>
hasMatch
(
s
,
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))?$'
);
/// Checks if length of data is LOWER than maxLength.
static
bool
isLengthLowerThan
(
dynamic
s
,
int
maxLength
)
{
...
...
@@ -425,11 +473,6 @@ class GetUtils {
return
numericOnlyStr
;
}
static
Regex
regex
=
Regex
();
}
class
RegexValidation
{
/// Returns whether the pattern has a match in the string [input].
static
bool
hasMatch
(
String
s
,
Pattern
p
)
=>
(
s
==
null
)
?
false
:
RegExp
(
p
).
hasMatch
(
s
);
}
...
...
lib/src/utils/regex/get_utils_extensions.dart
View file @
892b750
...
...
@@ -10,7 +10,7 @@ extension GetStringUtils on String {
bool
get
isAudioFileName
=>
GetUtils
.
isAudio
(
this
);
bool
get
isVideoFileName
=>
GetUtils
.
isVideo
(
this
);
bool
get
isTxtFileName
=>
GetUtils
.
isTxt
(
this
);
bool
get
isDocumentFileName
=>
GetUtils
.
is
Document
(
this
);
bool
get
isDocumentFileName
=>
GetUtils
.
is
Word
(
this
);
bool
get
isExcelFileName
=>
GetUtils
.
isExcel
(
this
);
bool
get
isPPTFileName
=>
GetUtils
.
isPPT
(
this
);
bool
get
isAPKFileName
=>
GetUtils
.
isAPK
(
this
);
...
...
@@ -23,7 +23,6 @@ extension GetStringUtils on String {
bool
get
isMD5
=>
GetUtils
.
isMD5
(
this
);
bool
get
isSHA1
=>
GetUtils
.
isSHA1
(
this
);
bool
get
isSHA256
=>
GetUtils
.
isSHA256
(
this
);
bool
get
isISBN
=>
GetUtils
.
isISBN
(
this
);
bool
get
isBinary
=>
GetUtils
.
isBinary
(
this
);
bool
get
isIPv4
=>
GetUtils
.
isIPv4
(
this
);
bool
get
isIPv6
=>
GetUtils
.
isIPv6
(
this
);
...
...
@@ -53,22 +52,6 @@ extension GetNumUtils on num {
}
extension
GetDynamicUtils
on
dynamic
{
/// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
bool
get
isNull
=>
GetUtils
.
isNull
(
this
);
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
// bool get isOneAKind => GetUtils.isOneAKind(this);
// bool isLengthLowerThan(int maxLength) =>
// GetUtils.isLengthLowerThan(this, maxLength);
// bool isLengthGreaterThan(int maxLength) =>
// GetUtils.isLengthGreaterThan(this, maxLength);
// bool isLengthGreaterOrEqual(int maxLength) =>
// GetUtils.isLengthGreaterOrEqual(this, maxLength);
// bool isLengthLowerOrEqual(int maxLength) =>
// GetUtils.isLengthLowerOrEqual(this, maxLength);
// bool isLengthEqualTo(int maxLength) =>
// GetUtils.isLengthEqualTo(this, maxLength);
// bool isLengthBetween(int minLength, int maxLength) =>
// GetUtils.isLengthBetween(this, minLength, maxLength);
}
...
...
lib/src/utils/regex/regex.dart
View file @
892b750
class
Regex
{
/// Username regex
Pattern
username
=
r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$'
;
/// Email regex
Pattern
email
=
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}$'
;
/// URL regex
Pattern
url
=
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\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"
;
/// Phone Number regex
/// Must started by either, "0", "+", "+XX <X between 2 to 4 digit>", "(+XX <X between 2 to 3 digit>)"
/// Can add whitespace separating digit with "+" or "(+XX)"
/// Example: 05555555555, +555 5555555555, (+123) 5555555555, (555) 5555555555, +5555 5555555555
Pattern
phone
=
r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$'
;
/// Hexadecimal regex
Pattern
hexadecimal
=
r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'
;
/// Image vector regex
Pattern
vector
=
r'.(svg)$'
;
/// Image regex
Pattern
image
=
r'.(jpeg|jpg|gif|png|bmp)$'
;
/// Audio regex
Pattern
audio
=
r'.(mp3|wav|wma|amr|ogg)$'
;
/// Video regex
Pattern
video
=
r'.(mp4|avi|wmv|rmvb|mpg|mpeg|3gp)$'
;
/// Txt regex
Pattern
txt
=
r'.txt$'
;
/// Document regex
Pattern
doc
=
r'.(doc|docx)$'
;
/// Excel regex
Pattern
excel
=
r'.(xls|xlsx)$'
;
/// PPT regex
Pattern
ppt
=
r'.(ppt|pptx)$'
;
/// Document regex
Pattern
apk
=
r'.apk$'
;
/// PDF regex
Pattern
pdf
=
r'.pdf$'
;
/// HTML regex
Pattern
html
=
r'.html$'
;
/// DateTime regex (UTC)
/// Unformatted date time (UTC and Iso8601)
/// Example: 2020-04-27 08:14:39.977, 2020-04-27T08:14:39.977, 2020-04-27 01:14:39.977Z
Pattern
basicDateTime
=
r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$'
;
/// Binary regex
/// Consist only 0 & 1
Pattern
binary
=
r'^[0-1]*$'
;
/// MD5 regex
Pattern
md5
=
r'^[a-f0-9]{32}$'
;
/// SHA1 regex
Pattern
sha1
=
r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})'
;
/// SHA256 regex
Pattern
sha256
=
r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}'
;
/// SSN (Social Security Number) regex
Pattern
ssn
=
r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'
;
/// IPv4 regex
Pattern
ipv4
=
r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$'
;
/// IPv6 regex
Pattern
ipv6
=
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}:))$'
;
/// ISBN 10 & 13 regex
Pattern
isbn
=
r'(ISBN(\-1[03])?[:]?[ ]?)?(([0-9Xx][- ]?){13}|([0-9Xx][- ]?){10})'
;
/// Passport No. regex
Pattern
passport
=
r'^(?!^0+$)[a-zA-Z0-9]{6,9}$'
;
/// Currency regex
Pattern
currency
=
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))?$'
;
/// Numeric Only regex (No Whitespace & Symbols)
Pattern
numericOnly
=
r'^\d+$'
;
/// Alphabet Only regex (No Whitespace & Symbols)
Pattern
alphabetOnly
=
r'^[a-zA-Z]+$'
;
/// Password (Easy) Regex
/// Allowing all character except 'whitespace'
/// Minimum character: 8
Pattern
passwordEasy
=
r'^\S{8,}$'
;
/// Password (Easy) Regex
/// Allowing all character
/// Minimum character: 8
Pattern
passwordEasyAllowedWhitespace
=
r'^[\S ]{8,}$'
;
/// Password (Normal) Regex
/// Allowing all character except 'whitespace'
/// Must contains at least: 1 letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal1
=
r'^(?=.*[A-Za-z])(?=.*\d)\S{8,}$'
;
/// Password (Normal) Regex
/// Allowing all character
/// Must contains at least: 1 letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal1AllowedWhitespace
=
r'^(?=.*[A-Za-z])(?=.*\d)[\S ]{8,}$'
;
/// Password (Normal) Regex
/// Allowing LETTER and NUMBER only
/// Must contains at least: 1 letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal2
=
r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9]{8,}$'
;
/// Password (Normal) Regex
/// Allowing LETTER and NUMBER only
/// Must contains: 1 letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal2AllowedWhitespace
=
r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9 ]{8,}$'
;
/// Password (Normal) Regex
/// Allowing all character except 'whitespace'
/// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal3
=
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)\S{8,}$'
;
/// Password (Normal) Regex
/// Allowing all character
/// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number
/// Minimum character: 8
Pattern
passwordNormal3AllowedWhitespace
=
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\S ]{8,}$'
;
/// Password (Hard) Regex
/// Allowing all character except 'whitespace'
/// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol)
/// Minimum character: 8
Pattern
passwordHard
=
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])\S{8,}$'
;
/// Password (Hard) Regex
/// Allowing all character
/// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol)
/// Minimum character: 8
Pattern
passwordHardAllowedWhitespace
=
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[\S ]{8,}$'
;
}
Please
register
or
login
to post a comment