Skip to content

Instantly share code, notes, and snippets.

@medeirosinacio
Last active June 9, 2022 14:20
Show Gist options
  • Save medeirosinacio/6a12627e1d0be0cab04936ab12c37666 to your computer and use it in GitHub Desktop.
Save medeirosinacio/6a12627e1d0be0cab04936ab12c37666 to your computer and use it in GitHub Desktop.
Expressões Regulares | Regex de diversos tipos para agilizar o desenvolvimento

☎️ ​Telefone

Tipo Regex Testar
(12) 3456-7891 ou (12) 3456-78910 /^\(\d{2}\) \d{4}-\d{4,5}$/gi 🔍
1234567891 ou 12345678910 /^\d{10,11}$/gi 🔍



📧 ​E-mail

Tipo Regex Testar
email@domain.com
email@domain.com.eu
^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/gi 🔍



🌎 ​ URL

Tipo Regex Testar
https://stackoverflow.com
http://localhost
^https?:\/\/(localhost|([a-z0-9-]+\.)+[a-z]{2,6}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:[0-9]+)?(\/?|\/\S+)$ 🔍



📫 ​CEP

Tipo Regex Testar
94900-000 /^\d{5}-\d{3}$/gi 🔍
94900000 /^\d{8}$/gi 🔍



🔑 ​UUID

Tipo Regex Testar
94900-000 /^\d{5}-\d{3}$/gi 🔍
94900000 /^\d{8}$/gi 🔍



🎣 ​Extract file name

Tipo Regex Testar
name.jpg ou name.name.doc /(.+?)(\.[^.]*$|$)$/gim 🔍
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment