dagda1
dagda1

Reputation: 28820

regex to filter out email addresses starting with a number or containing irregular characters

I want to filter out email addresses that start with a number of contain plus signs, for example:

[email protected]

or

reply+p-15549020-4d983e7b9e3d4ec45c5ae66473f90b765011a17c-4205@reply.github.com

I am using postres and I know I can do this to filter starting with a number

select address from email_addresses where address !~ '^\d';

But how can Include symbols like + and *?

Upvotes: 0

Views: 61

Answers (2)

Toto
Toto

Reputation: 91438

Have a try with this one:

select address from email_addresses where address !~ '^(\d|.*[*+])';

Upvotes: 1

anubhava
anubhava

Reputation: 785296

You can use:

select address from email_addresses where address !~ '^\d|[+*]';

[+*] is a character class that matches literal * or +

Upvotes: 2

Related Questions