regex to validate 'ABCD_EFG_HI_123'

Ankita9793
Tera Contributor

 

Hi All,

 

Can someone please help with the below regex to validate 'ABCD_EFG_HI_123'

 

var patt = new RegExp("^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_d{3}$"); 

Thanks in advance!
3 REPLIES 3

Bhavya11
Kilo Patron

hi @Ankita9793 ,

 

can you try something like this

 

var patt = /^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_[0-9]{3}$/; 
if(patt.test(testid)){
gs.info(patt.test(testid)); 
}

 

 

 

Please mark helpful & correct answer if it's really worthy for you.

 

 

Thanks,

BK

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Ankita9793 Try this 

var patt = new RegExp("^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_\\d{3}$");

Mark Manders
Mega Patron

^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_\d{3}$


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark