Using jQuery to find keywords in string
- by Nic Hubbard
In php, I have used preg_match_all() to find keywords (using the format %keyword%) in a string, which works wonderfully and returns an array of all found keywords.
What I would like to do, is do the same thing using jQuery or javascript. I have tried using the filter() function, and it kind of works. But I think I am missing something.
How can I find ALL instances of the keyword in a string, using a regex?
Here is what I have worked out so far:
$("[id^='editableContent-']").filter(function() {
alert($(this).html().match(/\%(.*?)\%/));
});
Any suggestions are welcome!