Rahul Rahul - 5 months ago 9
Java Question

How to create a regex expression for alphanumeric which contain 15 or 18 Characters

I wan to create

Regex Expresssion
which accept alphanumeric and should accept only
15 or 18
characters and I am storing the
regex expression
in database.

15 Number Example

78678AA1234B710


18 Number Example

78678AA1234B710A12

Answer

The simple answer would be

^(?:[\dA-Z]{18}|[\dA-Z]{15})$

Check it out here at regex101.

But you haven't given us much to go on.

Comments