I'm not so bad in regular expression but there I have a tiny problem, maybe one of you can answer this simple question.
I do this:
var myString = "10px";
var myRegexp = new RegExp("(\\d*\\.?\\d*){1}(em|ex|grad|ch|deg|ms|rad|rem|s|turn|vh|vw|vmin|vmax|px|cm|in|pt|pc|%)?", "gi");
myString.replace(myRegexp, function( match, number, type ){
console.log(match, number, type);
});
The replace console log two time, the first is : "10px", "10", "px" and I don't know why there is a second time, it return me that: ,,undefined (the two first value are not null or empty string, they return just nothing, absolutely empty).
My question, why the replace try a seconde replacing on nothing ? And how avoid it ?
{1}is completely pointless