# Check for a match if (/pat/) { ... } # Find all matches while (/pat/g) { ... }