Reputation: 2455
I would like to fetch one item in the string,
the main string is : This is an inactive AAA product. It will be replaced by replacement AAAA/BBBB number ABX16059636/903213712 during quoting
I would like fetch only "903213712", is there any way to achieve this one using Regex ?
Tried with below regex, it gives 16059636/903213712 == > I'm expecting only 903213712 after slash.
var string = "This is an inactive AAA product. It will be replaced by replacement AAAA/BBBB number ABX16059636/903213712 during quoting"
var result = string.match(/\d+/g)
//var resVal = result.toString().split("/");
alert(result);
Upvotes: 1
Views: 706
Reputation: 22490
you are almost done \/
is missing => /\/(\d+)/g
Explanation
\/
match the /
\d+
matches a digit (equal to [0-9]) .for more info see the demo regexvar string = "This is an inactive AAA product. It will be replaced by replacement AAAA/BBBB number ABX16059636/903213712 during quoting"
var result =/\/(\d+)/g.exec(string)
console.log(result[1]);
Upvotes: 8