Regular Expression issue

pramodkumar
Tera Expert

Hi All,

 

How to write Regular Expression to find out words start with ADC followed by numbers in a string. The numbers can be of either 1 or 2 or 3 or n digits.

 

For Ex: ADC3456

 

Thanks!

1 REPLY 1

AnveshKumar M
Tera Sage
Tera Sage

Hi @pramodkumar ,

Try this expression.

 

/ADC[0-9]+/g

Example:

 

var text = "Test ADC123"; 

var n = text.search(/ADC[0-9]+/g); //n will have the value as 5

 

Thanks,
Anvesh