0

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.

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by scarlettmoon
0

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

Edited by twiss: n/a

0

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.

0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.