The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Want to get a number from string

Gayathri5
Tera Guru

Hi Developers,

 

I have this string 

var a = "Remediation Task: VUL0011234 requesting Closed, False Positive state";

I want only Number i have used split but i am getting some , as well.

 

Please someone help me get only number from above string.

 

Much thanks in advance.

 

Regards,

G

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Try with this regex [A-Z]{3}\d{7}. Script would look something like below.

 

 

var a = "Remediation Task: VUL0011234 requesting Closed, False Positive state";
var number = a.match(/[A-Z]{3}\d{7}/g); // g is used to find multiple matches.
//var number = a.match(/[A-Z]{3}\d{7}/); // remove g to find first matche found.

 

 

View solution in original post

1 REPLY 1

Muhammad Khan
Mega Sage
Mega Sage

Try with this regex [A-Z]{3}\d{7}. Script would look something like below.

 

 

var a = "Remediation Task: VUL0011234 requesting Closed, False Positive state";
var number = a.match(/[A-Z]{3}\d{7}/g); // g is used to find multiple matches.
//var number = a.match(/[A-Z]{3}\d{7}/); // remove g to find first matche found.