Regex
grupojaque-ngx-commons › Globals › "lib/helpers/regex/regex.helper"
Index
Variables
Functions
Variables
Const
RegexEmail
• RegexEmail: RegExp‹› = /^\s@+@\s@+.\s@+$/
Defined in lib/helpers/regex/regex.helper.ts:36
Matches a general structure for emails: '...'@'...'.'...'
This won't check for the validity of domain extensions, or forbidden
patterns and characters other than not having more than two @
in the email.
Const
RegexURL
• RegexURL: RegExp‹› = /https?:\/\/(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi
Defined in lib/helpers/regex/regex.helper.ts:129
Const
RegexValidYoutubeId
• RegexValidYoutubeId: RegExp‹› = /[A-Za-z0-9_-]{11}$/
Defined in lib/helpers/regex/regex.helper.ts:84
Matches valid YouTube IDs (11-char base64 with '-' instead of '+' and '_' instead of '/')
Const
RegexYouTubeURL
• RegexYouTubeURL: RegExp‹› = new RegExp(
.*(?:youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=)(${stripRegex(
RegexValidYoutubeId
)}).*
)
Defined in lib/helpers/regex/regex.helper.ts:122
Will obtian the video ID from common YouTube URL structures
The returned value v
will contain:
- at
v[0]
the full url that matched - at
v[1]
the video ID that matches @RegexValidYoutubeId
Common YouTube URL structures include:
'...'youtu.be/{VideoID}
'...'watch/v=?{VideoID}
'...'v/{VideoID}
'...'u/''/{VideoID}
Functions
Const
RegexPassword
▸ RegexPassword(minLength
: number, maxLength?
: number): RegExp‹›
Defined in lib/helpers/regex/regex.helper.ts:57
Matches strings with 1 capital letter, 1 number, 1 symbol, and custom length.
When called like RegexPassword()
it'll use 8 as default minimum length.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
minLength | number | 8 | Minimum number of characters for the password |
maxLength? | number | - | Maximum number of characters for the password |
Returns: RegExp‹›
Const
stripRegex
▸ stripRegex(regex
: RegExp): string
Defined in lib/helpers/regex/regex.helper.ts:14
Takes a RegExp and returns only the content, without "/" delimiters or flags
Parameters:
Name | Type | Description |
---|---|---|
regex | RegExp | Regular Expresion to extract the content of |
Returns: string