Class RegexPattern
- Namespace
- NuvTools.Validation
- Assembly
- NuvTools.Validation.dll
Provides strongly-typed and pre-compiled regex patterns commonly used in the application. This class exposes both the raw pattern constants and pre-generated compiled Regex instances.
public static class RegexPattern
- Inheritance
-
RegexPattern
- Inherited Members
Methods
Base64ContentRegex()
[GeneratedRegex("^(?<content>(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))$", RegexOptions.Compiled|RegexOptions.CultureInvariant)]
public static Regex Base64ContentRegex()
Returns
Remarks
Pattern:
^(?<content>(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))$Options:
RegexOptions.Compiled | RegexOptions.CultureInvariantExplanation:
○ Match if at the beginning of the string.
○ "content" capture group.
○ Loop greedily any number of times.
○ Match a character in the set [+/-9A-Za-z] exactly 4 times.
○ Match with 3 alternative expressions.
○ Match a sequence of expressions.
○ Match a character in the set [+/-9A-Za-z] exactly 2 times.
○ Match the string "==".
○ Match a sequence of expressions.
○ Match a character in the set [+/-9A-Za-z] exactly 3 times.
○ Match '='.
○ Match a character in the set [+/-9A-Za-z] exactly 4 times.
○ Match if at the end of the string or if before an ending newline.
Base64DataUriRegex()
[GeneratedRegex("^data:(?<type>.+?\\/(?<extension>.+?));(?<base>.+),(?<content>(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))$", RegexOptions.Compiled|RegexOptions.CultureInvariant)]
public static Regex Base64DataUriRegex()
Returns
Remarks
Pattern:
^data:(?<type>.+?\\/(?<extension>.+?));(?<base>.+),(?<content>(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))$Options:
RegexOptions.Compiled | RegexOptions.CultureInvariantExplanation:
○ Match if at the beginning of the string.
○ Match the string "data:".
○ "type" capture group.
○ Match a character other than '\n' lazily at least once.
○ Match '/'.
○ "extension" capture group.
○ Match a character other than '\n' lazily at least once.
○ Match ';'.
○ "base" capture group.
○ Match a character other than '\n' greedily at least once.
○ Match ','.
○ "content" capture group.
○ Loop greedily any number of times.
○ Match a character in the set [+/-9A-Za-z] exactly 4 times.
○ Match with 3 alternative expressions.
○ Match a sequence of expressions.
○ Match a character in the set [+/-9A-Za-z] exactly 2 times.
○ Match the string "==".
○ Match a sequence of expressions.
○ Match a character in the set [+/-9A-Za-z] exactly 3 times.
○ Match '='.
○ Match a character in the set [+/-9A-Za-z] exactly 4 times.
○ Match if at the end of the string or if before an ending newline.
EmailRegex()
[GeneratedRegex("^([a-z0-9_\\-])([a-z0-9_\\-\\.]*)@((\\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\])|((([a-z0-9\\-]+)\\.)+([a-z]{2,})))$", RegexOptions.IgnoreCase|RegexOptions.Compiled|RegexOptions.CultureInvariant)]
public static Regex EmailRegex()
Returns
Remarks
Pattern:
^([a-z0-9_\\-])([a-z0-9_\\-\\.]*)@((\\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\])|((([a-z0-9\\-]+)\\.)+([a-z]{2,})))$Options:
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariantExplanation:
○ Match if at the beginning of the string.
○ 1st capture group.
○ Match a character in the set [-0-9A-Z_a-z\u212A].
○ 2nd capture group.
○ Match a character in the set [-.0-9A-Z_a-z\u212A] atomically any number of times.
○ Match '@'.
○ 3rd capture group.
○ Match with 2 alternative expressions.
○ 4th capture group.
○ Match '['.
○ Loop exactly 3 times.
○ 5th capture group.
○ 6th capture group.
○ Match with 4 alternative expressions.
○ Match a sequence of expressions.
○ Match '2'.
○ Match with 2 alternative expressions.
○ Match a sequence of expressions.
○ Match an empty string.
○ Match a character in the set [0-5].
○ Match a sequence of expressions.
○ Match an empty string.
○ Match a character in the set [0-9].
○ Match a sequence of expressions.
○ Match '1'.
○ Match a character in the set [0-9] exactly 2 times.
○ Match a sequence of expressions.
○ Match a character in the set [1-9].
○ Match a character in the set [0-9].
○ Match a character in the set [0-9].
○ Match '.'.
○ 7th capture group.
○ Match with 4 alternative expressions.
○ Match a sequence of expressions.
○ Match '2'.
○ Match with 2 alternative expressions.
○ Match a sequence of expressions.
○ Match an empty string.
○ Match a character in the set [0-5].
○ Match a sequence of expressions.
○ Match an empty string.
○ Match a character in the set [0-9].
○ Match a sequence of expressions.
○ Match '1'.
○ Match a character in the set [0-9] exactly 2 times.
○ Match a sequence of expressions.
○ Match a character in the set [1-9].
○ Match a character in the set [0-9].
○ Match a character in the set [0-9].
○ Match ']'.
○ 8th capture group.
○ Loop greedily at least once.
○ 9th capture group.
○ 10th capture group.
○ Match a character in the set [-0-9A-Za-z\u212A] atomically at least once.
○ Match '.'.
○ 11th capture group.
○ Match a character in the set [A-Za-z\u212A] atomically at least twice.
○ Match if at the end of the string or if before an ending newline.