Closed mlconnor closed 10 years ago
actually, if you wanted to make it just like google docs, it would be...
Formula.REGEXEXTRACT = function (text, regular_expression) {
var match = text.match(new RegExp(regular_expression));
return match ? (match.length == 1 ? match[0] : match.slice(1)) : null;
};
Updated source so that it works as expected.
thank you sir! I love killing forks. I love FormulJS, great work.
I noticed that REGEXEXTRACT can't handle capture groups. Google handles this as you can see here https://support.google.com/docs/answer/3098244
In their example, text = "(Content) between brackets" regex = '(([A-Za-z]+))'
returns 'Content'
I think that if the match call returns more than one element in the array then the first value should be returned instead of the entire match.
Current impl
Proposed