Home > Net >  Enclose expressions that include a word using a regular expresion in visual studio code
Enclose expressions that include a word using a regular expresion in visual studio code

Time:10-15

I have a script where I use many times the command

console.log('anything inside')

how can I change them with regular expression into visual code or any other editor, to be like this

if(display_comments==true){console.log('anything inside')}

where the "anything inside" and be any phrase.

CodePudding user response:

You can use search and replace with the following search:

console.log\('(.*)'\)

And replace with:

if(display_comments==true){console.log('$1')}

Don't forget to enable "Use regular expression" toggle next to the search input.

  • Related