From 2c1a8c85d22651acf584b95b4533f1b9fa264c7b Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 7 Mar 2019 22:33:29 +0800 Subject: [PATCH] repl: simplify regex expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/26496 Reviewed-By: Ruben Bridgewater Reviewed-By: Michaël Zasso Reviewed-By: Anto Aravinth Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- lib/repl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index ecf81a9ac3c288..3bc08274404b99 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1337,8 +1337,8 @@ function _memory(cmd) { if (cmd) { // Going down is { and ( e.g. function() { // going up is } and ) - var dw = cmd.match(/{|\(/g); - var up = cmd.match(/}|\)/g); + let dw = cmd.match(/[{(]/g); + let up = cmd.match(/[})]/g); up = up ? up.length : 0; dw = dw ? dw.length : 0; var depth = dw - up;