I have lots of files containing many calls to a specific method which used to accept objects but now requires an array. I would like to use Notepad++ to find/replace all of these calls with the required array.
Here's an example:
attach({ name: 'filename', url: 'fileURL' })
This needs to be converted to:
attach([{ name: 'filename', url: 'fileURL' }])
Any help with this would be much appreciated.
I'd search for:
attach\((.+)\)
and replace it with
attach([$1])
This will capture everything between attach's parentheses and adds a pair of square brackets around it.
edit: Older versions of notepad++ use \1 instead of $1 to refer to the 1st captured group.