Dan
Dan

Reputation: 23

REGEX 8 Characters

I need a Regex expression for PHP that finds exactly 8 characters in a string. The 8 characters have to be composed of both letters and numbers and no special characters.

EX: A1234567 or A123456A NOT 12345678 or AAAAAAAA

Upvotes: 2

Views: 132

Answers (1)

Mark Byers
Mark Byers

Reputation: 838256

You can do it with lookaheads:

"/^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]{8}$/i"

See it working online: ideone

Upvotes: 8

Related Questions