I need to do a regex capture/repalce on a file with content like the following. While I'm okay at matching things, I'm having trouble doing a capture replace.
I'd like to do the following:
- Capture which will be different in every instance.
- Add a new line before the copy line that references the table name.
So, for example, copy mytable( would become hello mytable\ncopy mytable(.
Sample Input
copy tablename(
preferredid= 'c0»',
qid= 'c0»' with null(''),
qpi= 'c0»',
ptid= 'c0»' with null(''))...
into '/idata2/backup/core/eq.ingres'
hello tablename\ncopy tablename?s/^(?=copy tablename\()/hello mytable\n/should do the trick.