PostgreSQL regex solution | clearly explained
IntuitionUse Regex to match patternsApproach~: like^: starts with-: represent range between letters or numbers, e.g., a-zA-Z0-9+: match the pattern [_a-zA-Z0-9]
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Use Regex to match patterns

# Approach
<!-- Describe your approach to solving the problem. -->

`~`: like

`^`: starts with

`-`: represent range between letters or numbers, e.g., `a-zA-Z0-9`

`+`: match the pattern `[_a-zA-Z0-9]` 1 or more times. must match the pattern

`\.`: escape and interpret `.` as a character. otherwise, the regex engine interprets it as "match any character"

`$`: mark the pattern's end, so no extra character is allowed after `$`

`*`: match the pattern 0, 1 or more times. It allows characters that do not match the pattern

# Note
Use `^[_a-zA-Z0-9]+` instead of `[_a-zA-Z0-9]*` since `*` allows characters that do not match the pattern.

For example, `!./@aa.com` could match the pattern `[_a-zA-Z0-9]*@[a-zA-Z]*\.com$` since `*` allows 0 match from substring `!./` to the sub pattern `[_a-zA-Z0-9]`.


# Code
```postgresql []
-- Write your PostgreSQL query statement below
select user_id, email
from Users
where email ~ '^[_a-zA-Z0-9]+@[a-zA-Z]*\.com$'
order by user_id
```
['PostgreSQL']