LeetCode - 3436. Find Valid Emails (Oracle)

조민수·2025년 3월 10일
0

LeetCode

목록 보기
70/73

Easy, SQL - REGEXP

RunTime : 876 ms


문제

Write a solution to find all the valid email addresses. A valid email address meets the following criteria:

  • It contains exactly one @ symbol.
  • It ends with .com.
  • The part before the @ symbol contains only alphanumeric characters and underscores.
  • The part after the @ symbol and before .com contains a domain name that contains only letters.

Return the result table ordered by user_id in ascending order.


풀이

  • 정규식을 통해 간단히 해결할 수 있다.
  • ^ : ~로 시작하는
  • [A-Za-z0-9_] : A ~ Z + a ~ z + 숫자 + _ 만 허용
  • \. : . 표시
  • $ : ~로 끝나는
SELECT user_id, email FROM Users
WHERE REGEXP_LIKE(email, '^[A-Za-z0-9_]+@[A-Za-z]+\.com$')
ORDER BY user_id;
profile
멈춤에 두려움을 느끼는 것

0개의 댓글

관련 채용 정보

Powered by GraphCDN, the GraphQL CDN