Teodoros
Teodoros

Reputation: 489

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

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.

Upvotes: 0

Views: 24

Answers (1)

Cristiano Schiaffella
Cristiano Schiaffella

Reputation: 609

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.

Upvotes: 1

Related Questions