Salo Cine
Salo Cine

Reputation: 3

Php check string for correct format

Looking for some help on how to validate a string in PHP.

My string contains:

all in one entry, so like 1234A12345.

I need to make sure/validate this before inserting in the DB.

Can one of the wizard help me out there?

Upvotes: 0

Views: 4160

Answers (1)

Jordan Kaye
Jordan Kaye

Reputation: 2887

This is a pretty simple regex:

/^\d{4}[a-zA-Z]\d{5}$/

And in case you haven't used regex in PHP before.

Upvotes: 3

Related Questions