Home > database >  Replace files content in VS code using Regex with original text
Replace files content in VS code using Regex with original text

Time:11-29

I have hundreds of files with different content like as

public delete(entity: Model1): Observable<any> {

public delete(entity: ModelABC): Observable<any> {

and I want to add one more parameter in the method like as below using VS code replace:

public delete(entity: Model1, simulate: boolean): Observable<any> {

public delete(entity: ModelABC, simulate: boolean): Observable<any> {

I have tried with below expression. but, It does not work correctly. Regex vs code

Any solution? How can I replace all the matching line with correct replacement?

CodePudding user response:

two error here :

  • First you need to catch the part you want to reuse with parenthesis.
  • Second, catch group starts from $1. ($0 contains the original match)

So, to do what you want, you'll need something like :

enter image description here

CodePudding user response:

This one helped me to replace all the files with new parameter:

Replace file content with regex

  • Related