I am trying to find replace thousands of strings in code - form.controls['property']
with form.get('property')
where property
is a variable.
So far I got find expression .controls\['\w+'\]
with replace expression .get\('\w+'\)
but VSCode is replacing .controls['products']
with .get\('\w+'\)
for string productForm.controls['products'].controls.length
. I need to replace it with productForm.get('products').controls.length
Any ideas how to fix it? Thanks!
Asked
Active
Viewed 69 times
1

Manish Jain
- 9,569
- 5
- 39
- 44
1 Answers
1
Parentheses ()
capture a group. Money sign $
accesses a group by index.
.controls\['(\w+)'\]
.get('$1')
This is the result in VS Code:

Shaun Luttin
- 133,272
- 81
- 405
- 467