/^(?!xn--|sthree-|sthree-configurator)(?!.*-s3alias$)(?!.*--ol-s3$)(?!.*(\.\.|--|__))(?!.*\.-|\.-|-$)[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/
This regex is designed to validate a string (likely a domain name, bucket name, or similar) by enforcing specific constraints on allowed characters and patterns. Here's a breakdown of the restrictions:
Allowed:
Hyphens (-), but with restrictions (see below). The total length of the string must be between 1 and 64 characters. Not Allowed:
The string must not start with: "xn--" (Reserved for internationalized domain names) The string must not end with: Forbidden Character Sequences: Hyphen followed by a dot (.-) Dot followed by a hyphen (-.) Must start with a lowercase letter (a-z) or digit (0-9). Must end with a lowercase letter (a-z) or digit (0-9). Can contain hyphens (-), but not at the start or end. Examples:
✅ Valid Strings:
❌ Invalid Strings:
xn--example (Starts with "xn--") sthree-example (Starts with "sthree-") sthree-configurator-test (Starts with "sthree-configurator") invalid-s3alias (Ends with "-s3alias") test--name (Contains "--") double..dot (Contains "..") bad__underscore (Contains "__") hyphen-.dot (Contains "-.") dot-.hyphen (Contains "-.") trailinghyphen- (Ends with "-")