ライブ プロジェクトがあり、正規表現を使用して電話番号から文字を除外する必要があります。
ライブなので、あまりいじることができないので、この正規表現を考えています:
^[^a-zA-Z]*$
あなたはそれがうまくいくと思いますか?文字を含む電話番号を削除しますか?
多文化サイトであるため、電話番号に文字を使用している国を知っていますか?
乾杯!
ライブ プロジェクトがあり、正規表現を使用して電話番号から文字を除外する必要があります。
ライブなので、あまりいじることができないので、この正規表現を考えています:
^[^a-zA-Z]*$
あなたはそれがうまくいくと思いますか?文字を含む電話番号を削除しますか?
多文化サイトであるため、電話番号に文字を使用している国を知っていますか?
乾杯!
Based on your current regex, I am assuming that you need a regex that will only match valid inputs.
Your current regex will work fine to prevent letters, but I think it would make more sense to figure out the minimum set of characters you consider valid and create a regex for that.
For example if you only want to allow digits you could use ^\d*$
or ^[0-9]*$
.
To also allow spaces, hyphens, and parentheses so a number like (123) 456-7890
would be valid:
^[\d \-()]*$