li*******@gmail.com wrote:
On Jan 27, 3:56 pm, "lihao0...@gmail.com" <lihao0...@gmail.comwrote:
>[...]
Please trim your quotes:
http://www.jibbering.com/faq/faq_not...s.html#ps1Post
>I've solved this problem by adding more newline patterns. since I need
to count only the vertical whitespaces(not tabs, spaces), so I can not
use /[\s\n\r]+$/.. The real purpose is to count the number of
newlines(blank lines) at the end of the textarea. So I actually went
with the following code:
var trailing_crs = textarea_element.value.match(/(?:\r\n|\r|\n|
\u0085|\u000C|\u2028|\u2029)+$/);
var num_crs = trailing_crs[0].length/2;
Actually, in my application, it might be better to use: '*' instead of
'+' in my regex pattern, otherwise I need to check trailing_crs
before using it, say:
var num_crs = trailing_crs ? trailing_crs[0].length/2 : 0;
while with /(....)*$/, I can just use trailing_crs directly:
var num_crs = trailing_crs[0].length/2;
The above code is error-prone, but I have no better solution as of yet other
than not to use the unnecessary, not universally supported non-capturing
parentheses.
However,
var num_nl = (s.match(...) || {0: ""})[0].length;
works fine since JavaScript 1.3 (NN 4.0), JScript 3.0 (MSHTML 4.0),
ECMAScript Ed. 3, so I don't think there is a need for inefficient
pattern matching (`a*') only to work around the reference issue.
http://PointedEars.de/es-matrix/
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16