I was playing with JavaScript regular expression, and the following case really puzzled me.
let reg = /(\d{1,3}[.]){3}\d{1,3}/g;
let str = "123.23.2.2.2";
let results = str.match(reg);
console.log(results);
I was expecting results to be ['123.23.2.2', '23.2.2.2'], but in reality, the console.log(results) outputs ['123.23.2.2']. What did I do wrong? The global search tag /g should give me all the matched results. I am really puzzled right now. Somebody help me!