From 3fa09c1446cd3296df763d18797d4985b3ae9c65 Mon Sep 17 00:00:00 2001 From: chenshiyu Date: Thu, 29 Aug 2019 14:23:14 +0800 Subject: [PATCH] feat/vivi/exercise7 --- lib/blink.js | 4 ++-- lib/capture.js | 8 +++++++- lib/capture_breakword.js | 8 +++++++- lib/quantified_group.js | 2 +- lib/quotes.js | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/blink.js b/lib/blink.js index c391a9f..9657462 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -2,6 +2,6 @@ var marked = require('marked') module.exports = function (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..0b643ce 100644 --- a/lib/capture.js +++ b/lib/capture.js @@ -1,3 +1,9 @@ module.exports = function (str) { - // TODO + const res = /x=\d+/.exec(str); + + if (res) { + return res[0].split(/=/)[1]; + } + + return null; } \ No newline at end of file diff --git a/lib/capture_breakword.js b/lib/capture_breakword.js index a08ee57..f367fd5 100644 --- a/lib/capture_breakword.js +++ b/lib/capture_breakword.js @@ -1,3 +1,9 @@ module.exports = function (str) { - // TODO + const res = str.match(/\bx=\+?\d+\b/); + + if (res) { + return res[0].replace('+', '').split(/=/)[1]; + } + + return null; } \ No newline at end of file diff --git a/lib/quantified_group.js b/lib/quantified_group.js index a08ee57..0298324 100644 --- a/lib/quantified_group.js +++ b/lib/quantified_group.js @@ -1,3 +1,3 @@ module.exports = function (str) { - // TODO + return str.match(/0x[A-Fa-f0-9]{2}/g).length === 8; } \ No newline at end of file diff --git a/lib/quotes.js b/lib/quotes.js index a08ee57..afcc47f 100644 --- a/lib/quotes.js +++ b/lib/quotes.js @@ -1,3 +1,3 @@ module.exports = function (str) { - // TODO + return str.match(/\".*?\"/g); } \ No newline at end of file