node.jsread-eval-print-loopnode-repl

How do you paste a multiline string into .editor mode?


I've got a SQL string that I'd like to run a regex against. I can't get it to paste correctly.

> .editor
// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)
s="with docs as (
    SELECT
        \"documentNumber\""

// (press Ctrl D here) 

s="with docs as (
  ^^^^^^^^^^^^^^^

Uncaught SyntaxError: Invalid or unexpected token

The first line works fine outside of .editor mode

> s="with docs as ("
'with docs as ('

> process.version
'v20.9.0'

How do you paste a multiline string into the .editor mode?


Solution

  • Try to use it with `` instead of "". It will not throw an error like the above. For example-

    s=`with docs as (
        SELECT
            \"documentNumber\"`
    

    I hope this will solve your problem.