I have a line like this:
var str = "When Home is on fire go and dance in fire"
I want the words homeandfire
For this, I used this Regex:
var words = str.match(/(home)|(fire)/ig)
and the output is as follows:
["Home", "fire", "fire"]
As you can see fire, matching twice, I want to ignore duplicate matches and show only once.
Thanks for the help.
source
share