我有一个包含一个或多个占位符的字符串,格式如下:$( [name] )
[ name]可以是任何单词(包含字母数字字符)并且区分大小写。
Example1: 'The $(Quick) Brown fox jumps over the lazy dog'
Example2: '$(the) $(Quick) Brown fox jumps over $(the) lazy dog'
Example3: '$(the) $(Quick) Brown $(fox) jumps over $(the) lazy $(dog)'
javascript中检索所有占位符的最佳方法是什么,以便我们得到以下结果:
Example1: ['Quick']
Example2: ['the', 'Quick', 'the']
Example3: ['the', 'Quick', 'fox', 'the', 'dog']
我还需要检索占位符的唯一列表,因此:
Example1: ['Quick']
Example2: ['the', 'Quick']
Example3: ['the', 'Quick', 'fox', 'dog']
谢谢你。