1

Have a bit of an issue. I need to replace all the console.log lines so that they match a logger function I have created.

Currently there is:

console.log("log message");

End result needed:

logger("log message","d");

Is there a way I can find and replace the start and end of the console log line without losing the message?

Using Visual Studio Code but can use other tools if needed.

luk2302
  • 55,258
  • 23
  • 97
  • 137
  • 1
    https://dev.to/rfornal/vs-code-search-and-replace-regex-mn2 – luk2302 Jan 07 '21 at 09:58
  • @luk2302 had a look at those. Currently trying to use console.log(.+?); followed with logger$1 however it gives me the group as being the whole ("log message") instead of just "log message". I have tried adding more brackets but have seemed to become stuck. – Cheeseslinger123 Jan 07 '21 at 10:17
  • 1
    Try `console.log\((.+?)\);` - `(` and `)` are considered regex symbol and need to be escaped. – luk2302 Jan 07 '21 at 10:22
  • 1
    @luk2302 just remembered that, Had the solution a minute before you replied. Thank you every much! – Cheeseslinger123 Jan 07 '21 at 10:27

0 Answers0