regex to validate 'ABCD_EFG_HI_123'
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 04:07 AM - edited 08-14-2024 04:50 AM
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!
Thanks in advance!
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 04:30 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 04:31 AM
Hi @Ankita9793 Try this
var patt = new RegExp("^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_\\d{3}$");
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 04:37 AM
^[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