我正在试图用form.controls['property']替换代码中的数千个字符串,其中property是一个变量。到目前为止,我找到了表达式.controls\['\w+'\]和replace表达式.get\('\w+'\),但是VSCode正在用.get\('\w+'\)代替.controls['products']来表示字符串productForm.controls['products'].controls.length。我需要用productForm.get('products').controls.length替换它,有什么办法可以修复它吗?谢谢!
发布于 2017-05-10 02:45:54
圆括号()捕获一个组。Money sign $按索引访问组。
.controls\['(\w+)'\]
.get('$1')这是VS代码中的结果:

https://stackoverflow.com/questions/43882233
复制相似问题