I've got the following string, defined in my Javascript code:
var s = "10px solid #101010";
Now, I want to get only the numeric initial part. For this purporse, I tried the following:
s.match(/^([0-9]+)/g);
It works like a charm, and the result was ['10']
.
After this test, I also tried to remove the g
modifier, as follows:
s.match(/^([0-9]+)/);
I expected the same result, but I was wrong. The result is an array with two solutions: ['10', '10']
.
Can someone explain me why? What is the meaning of the last element of the array, in the second case?