string = 'Hello 1234_ world 4567_ trap 456';
I need to capture all digits followed by underscore. Following code will do.
string.match(/(\d+?)(_)/gi);
However I tested following code and it worked except that underscore was also being captured.
(\d+)_
So I decided to give underscore its own capture group like this
(\d+)(_)
But it did not work. I am getting digits with trailing underscore. I do not want underscore.