📌  相关文章
📜  第 28 天:RegEx、模式和数据库简介hackerrank 解决方案 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:13.033000             🧑  作者: Mango

代码示例1
// Day 28: RegEx, Patterns, and Intro to Databases hackerrank solution javascript
function main() {
    const N = parseInt(readLine().trim(), 10);
    let pattern = new RegExp("@gmail.com");
    let names = [];
    
    for (let NItr = 0; NItr < N; NItr++) {
        const firstMultipleInput = readLine().replace(/\s+$/g, '').split(' ');

        const firstName = firstMultipleInput[0];

        const emailID = firstMultipleInput[1];
        
        if(pattern.test(emailID)){
            names.push(firstName);
        }
    }
    names.sort().forEach(name => {
        console.log(name);
    });
}