forum

Home / DeveloperSection / Forums / jQuery word counter - exclude string in brackets

jQuery word counter - exclude string in brackets

Anonymous User240111-May-2013
Hi Expert!

I have an jQuery function for word counting in textarea field. Everything works fine, but i need exclude words enclosed in triple brackets - [[[for example this string]]] from counter. How do I modify the regular expression to make it work?

    function word_count(field) {
        var number = 0;
        var matches = $(field).val().match(/\b/g);

        if (matches) {
            number = matches.length / 2;
        }
        wordCounts[field] = number;
        var wordCounter = 0;
        $.each(wordCounts, function(k, v) {
            wordCounter += v;

        });
        return wordCounter;
    }

Thanks in advance! 

Updated on 11-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By