Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正規表現が必要です。
任意の記号 (または文字?) または数字。ただし、数字だけを含むことはできません:
jhfj7484 - passes 3434jhfj - passes jку343hj - passes 63728134 - does not pass 6372813t - passes
助けてくれてありがとう。
これには正規表現は使用しません。PHP での例:
function mycheck($str) { return strspn($str, '0123456789') != strlen($str); } mycheck('12345'); // false mycheck('123asb'); // true
正規表現で言えば、次のように表現することもできます。
function mycheck($str) { return !preg_match('/^\d*$/', $str); }