From 07f5bac517c10a30ab20f8d6f5f29afc6e2d0d3f Mon Sep 17 00:00:00 2001 From: yiw Date: Sat, 24 Nov 2018 14:35:28 +0800 Subject: [PATCH] complete exercise7 --- lib/blink.js | 4 ++-- lib/capture.js | 2 ++ lib/capture_breakword.js | 2 ++ lib/quantified_group.js | 1 + lib/quotes.js | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/blink.js b/lib/blink.js index c391a9f..5724cc8 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -1,7 +1,7 @@ var marked = require('marked') module.exports = function (str) { - var md = marked(str) + var md = marked(str); // TODO - return null + return md.replace(/@@(.*?)@@/g, `$1`); } \ No newline at end of file diff --git a/lib/capture.js b/lib/capture.js index a08ee57..1770b34 100644 --- a/lib/capture.js +++ b/lib/capture.js @@ -1,3 +1,5 @@ module.exports = function (str) { // TODO + const res = str.match(/\=(\d+)/); + return res ? res[1] : null; } \ No newline at end of file diff --git a/lib/capture_breakword.js b/lib/capture_breakword.js index a08ee57..bb96b8d 100644 --- a/lib/capture_breakword.js +++ b/lib/capture_breakword.js @@ -1,3 +1,5 @@ module.exports = function (str) { // TODO + const res = /\bx=(\d+)\b/.exec(str); + return res ? res[1] : null; } \ No newline at end of file diff --git a/lib/quantified_group.js b/lib/quantified_group.js index a08ee57..6ebc363 100644 --- a/lib/quantified_group.js +++ b/lib/quantified_group.js @@ -1,3 +1,4 @@ module.exports = function (str) { // TODO + return /^(0x[a-fA-F0-9]{2}\s*){8}$/.test(str); } \ No newline at end of file diff --git a/lib/quotes.js b/lib/quotes.js index a08ee57..bc2e677 100644 --- a/lib/quotes.js +++ b/lib/quotes.js @@ -1,3 +1,4 @@ module.exports = function (str) { // TODO + return str.match(/\".*?\"/g); } \ No newline at end of file