링크
https://leetcode.com/problems/find-users-with-valid-e-mails/description/
문제
Write a solution to find the users who have valid emails.
A valid e-mail has a prefix name and a domain where:
The prefix name is a string that may contain letters (upper or lower case), digits, underscore '_', period '.', and/or dash '-'. The prefix name must start with a letter.
The domain is '@leetcode.com'.
Return the result table in any order.
The result format is in the following example.
정답
select *
from Users
where mail regexp '^[a-zA-Z][a-zA-Z0-9_.-]*@leetcode[.]com$'
# 해설
[a-zA-Z] = means mail should start from small or capital letter.
[a-zA-Z0-9_.-] = after that any letter or number or _ or . or -
@leetcode = after that combine with @leetcode
[.] = must come . after @leetcode
com = then com.
새롭게 이해한 내용
- 정규식 기호
. : 문자 하나를 나타낸다.
* : 앞에 나온 문자의 0개 이상 반복을 나타낸다.
^ : 문자열의 처음을 나타낸다.
$ : 문자열의 끝을 나타낸다.
[.] : 괄호 안의 문자열 일치를 확인한다.
{.} : 반복을 나타낸다.
| : or 를 나타낸다.
(관련 URL)https://dev.mysql.com/doc/refman/8.4/en/regexp.html
'[업무 지식] > MySQL' 카테고리의 다른 글
[row index] Weather Observation Station 20 (0) | 2024.11.25 |
---|---|
[left, right] Weather Observation Station 8 (0) | 2024.11.19 |
[GROUP_CONCAT] Group Sold Products By The Date (0) | 2024.11.18 |
[Limit/Offset] Second Highest Salary (0) | 2024.11.18 |
[delete] Delete Duplicate Emails (0) | 2024.11.14 |