Help with a Regular Expression

Hi everyone, I am new to this and wonder if you could help with the creation of a regular expression for the following sets of letter/digits combinations:-

The full combination is either 5 - 7 items long.

It always begin with the letter B
The second letter ranges between A-H
The 3 letter digit could range between 0-9 or letters S B U D Z P

4th is a number 0-9
5th is a number 0-9
6th is a number 0-9 but not always included
7th is a number 0-9 but not always included

If this can be created, I would be very grateful.

Thanks

http://rubular.com/ is a great tool for this kinda stuff
[B][A-H](\d||[S,B,U,D,Z,P])\d{3}
I made that one really fast, it’s not optimized at all
This is a pretty ugly regex, and it doesn’t fit ALL of your parameters but it works fair enough.

2 Likes

Thanks for your help :grin: