Regexps (regular expressions) are very powerful and robust tool to use in PostgreSQL. You’re probably familiar with the syntax:
My tip for today is - use regexp with
CHECK column constraints! For example:
This will ensure that login will consist only of alphanumerical characters, hyphens and/or underscores and it cannot be shorter than 3 characters. I love it!