What does this short regular expression match?
/\[img\]([^[]*)\[\/img\]/ig This part is of interest: ([^ [] *)
As far as I can tell, the following are made up here:
[^[] - not equal to the symbol [ But everything else is allowed (why it is necessary, because in the bracket group there should be a url link to the image, for example.
* - greedy quantifier, is equal to zero or more characters (why is there zero? I think there should be a + )
var reg2 = /\[img\]([^[]*)\[\/img\]/ig; var match2,text_str; while (match2 = reg2.exec(text)) { console.log(match2); }