0

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?

1
  • 2
    You need to capture the value you want to repeat ([A-Za-z0-9]+) and captured value references start at $1. so find: public delete\(entity: ([A-Za-z0-9]+)\): Observable<any> \{ replace: public delete(entity: $1, simulate: boolean): Observable<any> { Commented Nov 28, 2022 at 8:19

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Replace file content with regex

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.