Regular Expression Help


Can someone help me with a regular expression we have a code at the moment that restricts the submission of letter/numbers as follows:

1st letter is always a B
2nd letter is A - H
3rd is either B, C, D, G, S, P Z or 0 - 9
4th is either U or 0 - 9
followed by 0 - 9 on 5th, 6th, 7th & 8th digit however the length of the entry can range between 5 -8 digits long.

I currently have expression: [B]A-H\d{2} however this leaves the expression open ended. The code makes the entry specific but after the 8th digit you can enter anything.

Any help would be greatly appreciated.


If you look at your post you’ll see that there’s a lot missing from your regexp. There is a button in the editor for marking something as code, keeping it intact. (Always proofread your questions)

1 Like

Sorry was in a rush :see_no_evil:, this is all very new to me and I’m looking for a quick win with the code.