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.
PHPでフォームテキストボックスの英数字文字列をバリデーションしたいです。数字や「.」などの特殊文字を含めることができます。および「-」を使用できますが、文字列に数字と特殊文字のみを含めることはできません。コードを手伝ってください。
これを試して
// Validate alphanumeric if (preg_match('/^[a-zA-Z]+[a-zA-Z0-9._]+$/', $input)) { // Valid } else { // Invalid }
私は正規表現に慣れていませんが、次のようにします:
preg_match('/^[\w.-]+$/', input)