Regex to validate a catalog variable

Aditya Banka2
Tera Guru

Hi There,

I have a requirement to validate a catalog variable which the help of regex which should satisfy the below criteria.

 

Ex 1 : bldg724 - Meeting room

Ex 2 : bldgKN1 - Magnum

 

1. String should always start with bldg

2. Followed by exactly 3 characters ([0-9a-zA-Z])

3. Followed by a Space

4. Followed by a - (hyphen)

5. Followed by a Space

6. Followed by any string

 

If the above criteria doesn't match, throw an error. Please help me in building the regex.

1 REPLY 1

Harshad Wagh
Tera Guru

pls try this.

^bldg[0-9a-zA-Z]{3} - .+$

 

Thanks

Harshad