Let’s examing below expression one by one:
(\d{3,4}[.-]?)+
(
: open a capturing group\
: start character shorthand (escape the following character)d
: match all Arabic digits, like [0-9]{3,4}
: match 3 or 4 of the preceding character
{
: open a quantifier3
: match 3 of the preceding character,
: separate the min and max values4
: match 4 of the preceding character}
: close the quantifier[.-]?
: match 0 or 1 of the preceding character
[
: open a character class.
: match any character-
: leteral character to match a hyphen]
: close the character class?
: match 0 or 1 of the preceding character)
: close the capturing group+
: match 1 or more of the preceding characterImproved expression:
(\d{3}[.-]?){2}\d{4}
Date: 2025/04/28