개요[ | ]
- JS10 Day 7: Regular Expressions I
JavaScript
Copy
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});
main();
});
function readLine() {
return inputString[currentLine++];
}
JavaScript
Copy
function regexVar() {
/*
* Declare a RegExp object variable named 're'
* It must match a string that starts and ends with the same vowel (i.e., {a, e, i, o, u})
*/
let re = /^([aeiou]).*\1$/;
/*
* Do not remove the return statement
*/
return re;
}
JavaScript
Copy
function main() {
const re = regexVar();
const s = readLine();
console.log(re.test(s));
}
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.