Table of Contents

Class RegexPattern

Namespace
NuvTools.Validation.Brazil
Assembly
NuvTools.Validation.dll

Regex patterns class.

public static class RegexPattern
Inheritance
RegexPattern
Inherited Members

Methods

MobileNumberRegex()

[GeneratedRegex("^(?<CodeArea>11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|37|38|41|42|43|44|45|46|47|48|49|51|53|54|55|61|62|63|64|65|66|67|68|69|71|73|74|75|77|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)(?<FirstDigit>9)(?<Number>\\d{8})$")]
public static Regex MobileNumberRegex()

Returns

Regex

Remarks

Pattern:

^(?<CodeArea>11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|37|38|41|42|43|44|45|46|47|48|49|51|53|54|55|61|62|63|64|65|66|67|68|69|71|73|74|75|77|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)(?<FirstDigit>9)(?<Number>\\d{8})$

Explanation:
○ Match if at the beginning of the string.
○ "CodeArea" capture group.
    ○ Match with 9 alternative expressions.
        ○ Match a sequence of expressions.
            ○ Match '1'.
            ○ Match a character in the set [1-9].
        ○ Match a sequence of expressions.
            ○ Match '2'.
            ○ Match a character in the set [12478].
        ○ Match a sequence of expressions.
            ○ Match '3'.
            ○ Match a character in the set [1-578].
        ○ Match a sequence of expressions.
            ○ Match '4'.
            ○ Match a character in the set [1-9].
        ○ Match a sequence of expressions.
            ○ Match '5'.
            ○ Match a character in the set [13-5].
        ○ Match a sequence of expressions.
            ○ Match '6'.
            ○ Match a character in the set [1-9].
        ○ Match a sequence of expressions.
            ○ Match '7'.
            ○ Match a character in the set [13-579].
        ○ Match a sequence of expressions.
            ○ Match '8'.
            ○ Match a character in the set [1-9].
        ○ Match a sequence of expressions.
            ○ Match '9'.
            ○ Match a character in the set [1-9].
○ "FirstDigit" capture group.
    ○ Match '9'.
○ "Number" capture group.
    ○ Match a Unicode digit exactly 8 times.
○ Match if at the end of the string or if before an ending newline.

ZipCodeRegex()

[GeneratedRegex("^\\d{5}-?\\d{3}$")]
public static Regex ZipCodeRegex()

Returns

Regex

Remarks

Pattern:

^\\d{5}-?\\d{3}$

Explanation:
○ Match if at the beginning of the string.
○ Match a Unicode digit exactly 5 times.
○ Match '-' atomically, optionally.
○ Match a Unicode digit exactly 3 times.
○ Match if at the end of the string or if before an ending newline.