Test, validate and match regular expressions
Validates Brazilian phone numbers (both mobile and landline) using named capture groups for each component: an optional country code (DDI) like +55 or 0055, an area code (DDD) with optional parentheses and leading zero, an optional 9th digit for mobile numbers, and the 8-digit subscriber number in 4-4 format. It tolerates flexible separators such as spaces, hyphens, and dots between segments. Written for JavaScript (ECMAScript) with gm flags for global multiline matching.