I have a js string…
var string = "Hi how are you <b>today</b>";
I now have a new js string…
var newstring = "are today";
I want to remove all the words from var string that don’t match var newstring. I would also like to keep the tags that are associated with those words, if any.
Example Result:
are <b>today</b>
There are some simpe ways to do something like this, if they will work for you depends on what you intend to use this for, but something like this maybe:
FIDDLE