How to String.match() distinct it ${SOME_TEXT} using Regex
问题 I need this string: var x = 'Hi ${name}! How are you? ${name}, you are old! ${name} share with ${other} how do u ${feel}!' I need to know using Regex how much distinct ${ANY_THING} exists. In example above i expect 3: ${name}, ${other}, ${feel} I'm trying it: x.match(\${([a-zA-Z])) But the output is wrong :( Thanks! 回答1: I need to know using Regex how much distinct ${ANY_THING} exists x.match(/\$\{[^\}]+\}/g) .sort() .filter(function(element, index, array) { return index == array.indexOf