LoginSignup
1
0

More than 1 year has passed since last update.

【PHP・Laravel】パターン別電話番号のバリデーション

Posted at

結構実装することはあるのですが、その度に正規表現ってどうやってっけ?ってなって調べてるので、自分用にメモ。
間違っていたら、ご指摘いただけると助かります。

ハイフンなし

'/^0[0-9]{9,10}$/u'

ハイフンあり

'/^0[0-9]{1,4}-[0-9]{1,4}-[0-9]{3,4}\z/'

ハイフンありなし両方許容

'/^(0{1}\d{1,4}-{0,1}\d{1,4}-{0,1}\d{4})$/'
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0