質問

php ...

のregexpに関連しています。

ポルトガルの携帯電話をフィルタリングするには、 regexp を作成する必要があります。(私はそれを理解しています)

規則:

The integer/string must have 9chars;
The first char must be a '9';
The second one can be '1,2,3,6' (Chars are separeted by commas);
The other chars must be in range of '0-9';
.

役に立ちましたか?

解決

#9[1236][0-9]{7}#
.

それはそれをするべきです;)

説明:

# <-- delimiter
    9 <-- 9
    [1236] <-- either of the chars in the brackets
    [0-9]{7} <-- 0-9  7 times
# <-- delimiter
.

使用:有効な電話番号が有効な電話番号かどうかを確認したい場合は、

$isValid = preg_match('#^9[1236][0-9]{7}$#', $phoneNumber);
.

^$に注意してください。これらは電話番号だけがもうありません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top