AHMAD ASHFAQ
AHMAD ASHFAQ

Reputation: 83

Regex for registration number

I'm new with regular expretions. Don't know how to do. Here it's a regex format

reg_no xx(F/S)-(BS/MS)(CS/SE)-x

example of registration number

reg_no 13F-BSSE-4

Solution is

"/^(reg)_(no) [0-9]{2}[(BS)|(MS)]{2}[(CS)|(SE)]{2}\-[0-9]{1}$/"

Upvotes: 0

Views: 448

Answers (1)

rock321987
rock321987

Reputation: 11032

You can use

^reg_no [0-9]{2}[FS]-(?:[BM]S)(?:CS|SE)-[0-9]$

Regex Demo

Upvotes: 2

Related Questions