From 201026740933c2ed35b5daec362ee2ad6ebffe7a Mon Sep 17 00:00:00 2001 From: luckylooky2 Date: Thu, 23 May 2024 11:29:23 +0900 Subject: [PATCH] =?UTF-8?q?5.23:=20regex(=ED=95=9C=EA=B5=AD=EC=9D=B4=20?= =?UTF-8?q?=EA=B7=B8=EB=A6=AC=EC=9A=B8=20=EB=95=90=20=EC=84=9C=EB=B2=84?= =?UTF-8?q?=EC=97=90=20=EC=A0=91=EC=86=8D=ED=95=98=EC=A7=80,=20=EA=B0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B8=B4=20=EB=8B=A8=EC=96=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baekjoon/5637.js | 15 +++++++++++++++ baekjoon/9996.js | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 baekjoon/5637.js create mode 100644 baekjoon/9996.js diff --git a/baekjoon/5637.js b/baekjoon/5637.js new file mode 100644 index 0000000..03b8003 --- /dev/null +++ b/baekjoon/5637.js @@ -0,0 +1,15 @@ +// 가장 긴 단어 : 정규 표현식 +const input = require("fs").readFileSync("/dev/stdin").toString().trim(); +const text = input; +const regex = /[A-Za-z-]+/g; +let answer = ""; + +const candidates = text.match(regex); + +for (const word of candidates) { + if (answer.length < word.length) { + answer = word; + } +} + +console.log(answer.toLowerCase()); diff --git a/baekjoon/9996.js b/baekjoon/9996.js new file mode 100644 index 0000000..12d5f7f --- /dev/null +++ b/baekjoon/9996.js @@ -0,0 +1,20 @@ +// 한국이 그리울 땐 서버에 접속하지 : 정규 표현식 +const input = require("fs") + .readFileSync("/dev/stdin") + .toString() + .trim() + .split("\n"); +const n = Number(input.shift()); +const strings = input; +const [start, end] = input.shift().split("*"); +const regex = new RegExp(`^${start}[a-z]*${end}$`); +const answer = []; + +for (const string of strings) { + const res = regex.test(string); + answer.push(res ? "DA" : "NE"); +} + +console.log(answer.join("\n")); + +// 17'00"