Question

I have array of keywords. How can I find if any of these keywords present in textarea? Is there any plugin or function to do that?

Thank you

Was it helpful?

Solution

var words = $('#text').val().split(/\b[\s,\.-:;]*/);
var keywords = ['keyword1', 'keyword2'];

var isKeywordPresent = $.grep(keywords, function(keyword, index) {
    return $.inArray(keyword, words) > 0;
}).length > 0;

OTHER TIPS

for some ideas @SO Find text string using JQuery?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top