The REGEX function in Salesforce checks whether a text value matches a pattern and returns TRUE or FALSE. It is the standard way to enforce formats such as ZIP codes, phone numbers, product codes or IDs in validation rules, for example NOT(REGEX(BillingPostalCode, "\\d{5}")) blocks any postal code that isn’t exactly five digits.
Most REGEX tutorials stop at the syntax. In this one, I also tested the behaviour that trips people up in a Salesforce Developer Edition org: whole-value matching, case-insensitive matching with (?i), and where REGEX can’t be used, plus a pattern cheat sheet and ready-to-use validation rules.