Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The three regexp that I've designed to do this in JavaScript are:
Any one of these go with the statement:1. re = /<div class="blockqte">((?:[^<]|<\/?s)*)<\/div>/g; 2. re = /<div class="blockqte">((?:[^<]*|<\/?s)*)<\/div>/g; 3. re = /<div class="blockqte">((?:.|\n)*?)<\/div>/g;
My understanding and please correct me if I'm wrong, is that expression number 3 is inefficient since it leaves the grouping with each of its evaluations to check the remainder of the expression (i.e. </div>). However, in 1 and 2 the group is left only with the first failure in matching all of its alternatives. That seems to make 1 and 2 better choices and it's here that I'm not sure of the advantages of one over the other. Can any one help with this?str = str.replace(re, "<pre>$1</pre>");
|
---|