I am trying to extract the integers from a string.
String :
Str = "(Start = 10) AND (End_ = 40)"
Note: The integers here can range from 1 - 999, single digit to three digits
Desired Output:
No1 = 10
No2 = 40
This code will get you what you want, an array of numbers found in the string.
The regular expression looks for a single number 1 through 9 [1-9] followed by 0, 1, or 2 {0,2} numbers between 0 through 9 [0-9]. The g means global, which instructs match() to check the entire string and not stop at the first match.
var str = "(Start = 10) AND (End_ = 40)";
var numbers = str.match(/[1-9][0-9]{0,2}/g);
console.log(numbers);
00[1-9]|0[1-9]\d|[1-9]\d{2}20455 will also match. You'd need to add a boundary condition or two.