Working with javascript / jquery - Need to have a more precise regex for the following pattern:

Should I have the ignore case included? If so where?

X25b777s44K

The regex I have:

^([A-Z]?)(\d{2})([a-z]?)(\d{3})([a-z]?)(\d{2})([A-Z]?)$

Thank you for your help.

Are the letters optional? Do you want to match all the parts of this? If both not, and if you want case-insensitivity, use something like:

/^[a-z]\d{2}[a-z]\d{3}[a-z]\d{2}[a-z]$/i

Hi ~ Thanks for your reply. Actually the letters are NOT optional, have to be caps and yes need to match all parts of the sequence.

With this scenario, would your solution work?

Thank you.

All of the letters need to be caps?

/^([A-Z])(\d{2})([A-Z])(\d{3})([A-Z])(\d{2})([A-Z])$/

But this will NOT match X25b777s44K.

Not all caps but thank you. What I have is working great. Thanks again for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.