I need a function to return all matches of a regexp in a string and positions at which the matches are found (I want to highlight matches in the string).
There
Use the captures method on a successful match.
"foobar".match(/(f)(oobar)/).captures
=> ["f,""oobar"]