I have a word counter JS script which is counting words in a form field and
I think I have a problem with (uurgh) my RegEx... ;-)  I want to ensure that
when a user enters say "That's all folks" that the function actually counts
that as 3 words.  At the moment, its counting it as over 3.    Am I missing
a simple regex string for it to recognise it as 3?

here is a snippet of the crucial but
========================
var char_count = this_field.value.length;
        var fullStr = this_field.value + " ";
        var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
        var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
        var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
        var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, "
");
        var splitString = cleanedStr.split(" ");
        var word_count = splitString.length -1; 

========================

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to