令牌可以是这样的{num}或{num:2}(2 是 arg)
我想实现这样的匹配:
// no args
[0] = num
// args (anything after the colon and before the closing brace as one match is fine)
[0] = num
[1] = 2
我设法匹配大括号中的任何东西,但我的正则表达式太菜鸟,无法得到比这更复杂的东西!谢谢。
仅供参考,我正在使用 javascript 并\{(.*?)\}匹配其中的所有内容。