I'm trying to parse string in JavaScript and find all unique words, which starts with :
symbol. I wrote that regular expression for this purpose:
/(:[A-z]\w+)(?!.*\1)/g
It works fine for this string:
"test :one :one test :one test :two".match(/(:[A-z]\w+)(?!.*\1)/g)
And result is [':one', ':two']
Online example #1
But, if after word goes new line symbol
"test :one\n :one test :one test :two".match(/(:[A-z]\w+)(?!.*\1)/ig)
Regex not working properly and returns [':one', ':one', ':two']
Online example #2
How to modify this regex and get only unique results?