How can I get the reference directly after a matched word including the matched word in regex
Example
var refArray = [];
var str = "matt 25:5 hello foo bar matt 5:10"; // unknown information
var pattern = "matt"; // looped through an object to get pattern
var regex = new RegExp(pattern,"gi");
var matches = str.match(regex); // check for any name matches
if(matches){
/*
This is where I get stuck
Get the numbers right after each match
and place both name and number into a variable AKA. result
*/
refArray.push($result);
}
// The refArray should output [matt 25:5, matt 5:10]
Thank You for your help it is appreciated
EDIT
I'd like to be able to match all reference possibilities AKA example... Matt | Matt 5 | Matt 5:5 | Matt 5:5-10 | Matt 5:5-10, 12 | Matt 5:5-10, 12-14
EDIT
This is the Regex I came up with located here
I am trying to match all possible references
matt
matt 5
matt 5, 6, 7
matt 5:5
matt 5:5-10
matt 5:5-10, 16,
matt 5:5-10, 16-20, 18-20
matt 5-6
And according to the site I am, but when I paste the code into my page it still only comes up with the name.
The Regex is...
(matt( \d*(\:\d*)?(\-\d*)?((, (\d*\-)?\d*)?)+)?(?!\w))
what am I doing wrong?