문서 편집 권한이 없습니다. 다음 이유를 확인해주세요: 요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다: 사용자. 문서의 원본을 보거나 복사할 수 있습니다. ==개요== HR30 Day 28: RegEx, Patterns, and Intro to Databases * https://www.hackerrank.com/challenges/30-regex-patterns/problem {{HR30 헤더}} {{HR30 20-29}} |} ==Java== <syntaxhighlight lang='Java'> import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; class Row { public String firstName; public String emailID; public Row(String firstName, String emailID) { this.firstName = firstName; this.emailID = emailID; } } public class Solution { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int N = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); List<Row> rows = new ArrayList<Row>(); for (int NItr = 0; NItr < N; NItr++) { String[] firstNameEmailID = scanner.nextLine().split(" "); String firstName = firstNameEmailID[0]; String emailID = firstNameEmailID[1]; if( !firstName.matches("^[a-z]{1,20}$") ) continue; if( !emailID.matches("^[a-z\\.]{1,40}@gmail.com$") ) continue; rows.add(new Row(firstName,emailID)); } scanner.close(); rows.sort(new Comparator<Row>() { public int compare(Row r1, Row r2) { return r1.firstName.compareTo(r2.firstName); } }); for(Row row: rows) { System.out.println(row.firstName); } } } </syntaxhighlight> ==PHP== <syntaxhighlight lang='php'> <?php $stdin = fopen("php://stdin", "r"); fscanf($stdin, "%d\n", $N); $rows = []; for ($N_itr = 0; $N_itr < $N; $N_itr++) { fscanf($stdin, "%[^\n]", $firstNameEmailID_temp); $firstNameEmailID = explode(' ', $firstNameEmailID_temp); $firstName = $firstNameEmailID[0]; $emailID = $firstNameEmailID[1]; if(preg_match('/^[a-z]{1,20}$/',$firstName)<1) continue; if(preg_match('/^[a-z\.]{1,40}@gmail.com$/',$emailID)<1) continue; $rows[] = ['firstName'=>$firstName,'emailID'=>$emailID]; } fclose($stdin); usort($rows, function($a,$b) { return $a['firstName'] > $b['firstName']; }); foreach($rows as $row) { echo $row['firstName'] . "\n"; } </syntaxhighlight> ==Python== <syntaxhighlight lang='python'> #!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': N = int(input()) rows = [] reFirstName = re.compile("^[a-z]{1,20}$") reEmail = re.compile("^[a-z\\.]{1,40}@gmail.com$") for N_itr in range(N): firstNameEmailID = input().split() firstName = firstNameEmailID[0] emailID = firstNameEmailID[1] if not reFirstName.match(firstName): continue if not reEmail.match(emailID): continue rows.append({'firstName':firstName,'emailID':emailID}) for row in sorted(rows, key=lambda k: k['firstName']): print( row['firstName'] ) </syntaxhighlight> 이 문서에서 사용한 틀: 틀:Ed (원본 보기) 틀:HR30 20-29 (원본 보기) 틀:HR30 헤더 (원본 보기) 틀:언어아이콘 (원본 보기) 틀:언어이미지 (원본 보기) HR30 Day 28: RegEx, Patterns, and Intro to Databases 문서로 돌아갑니다.