I would like to remove the line in between this filtered search:
Here is the regex that I have in my Search in VS Code - ^(?![ \t]*//).*^.*\bif\b.*$\n\n(?![ \t]*//).*^.*\breturn\b.*$
I would like to get rid of the line in between the if and the return but keep the code, just remove the line in between. I know I can keep the result with the $0
but cant figure out the next part, any help would be much appreciated!
Here is an example of what I want in the results:
if o.R == nil {
return nil
}
Here are some examples of what I do not want in the results:
if err != nil {
return err
}
Also unwanted in the results:
if foreign.R == nil {
foreign.R = &portfolioBinOperationR{}
return nil
}
Here is the my VSCode after trying your solution...where am I going wrong?
CodePudding user response:
Search by (if.*?\{)([\s\n]{2,}?)(?=^.*?return)
and replace with $1\n
. See the regex