Read more

Commonly used regular expressions - Cheatsheet

Deleted user #6
June 09, 2011Software engineer

For Email-Patterns see most recent E-Mail-Pattern.

HOST = /\A[a-z0-9]+[a-z0-9\-\.]*[a-z0-9]+\z/i
BANK_CODE = /\A\d{8}\z/                                          # Germany
BANK_ACCOUNT_NUMBER = /\A\d{1,10}\z/                             # Germany
ZIP_CODE = /\A\d{5}\z/                                           # Germany
HEX_COLOR = /\A([a-fA-F0-9]{3}){1,2}\z/
IP_ADDRESS = /\A(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}\z/
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

We usually put these constants in a Pattern class, so we can call them like Pattern::EMAIL.

Posted to makandra dev (2011-06-09 09:56)