This is my regex: (-?\d+)-(-?\d+).
The purpose is to match strings that denote ranges, including negative ones. For example:
1-100-100-1-10, but also:-100--10
Then with my regex, I will capture the first number, the last, but also the whole string. In Angular:
let regExp : RegExp = RegExp('(-?\\d+)-(-?\\d+)', 'g');
let values: RegExpExecArray = regExp.exec('-100--10');
From the values result, I can use positions values[1] and values[2], as values[0] is reserved for the whole string.
Obviously, the above works for me, but do you have any idea how to make my regex more precise? I.e. I don't want the whole string to be matched.
AppConstants.ROLLING_DEP_DATE_REGEX? Why not use the regexp to match what you describe? (e.g./(-?\d+)-(-?\d+)/g)