Question Regular Expressions
A single reference page for common regex patterns you can reuse across question fields (like catalog item variables).
How Question Regular Expressions Work
- Create a record in Service Catalog > Catalog Variables > Variable Validation Regex with the regex and validation message.
- Reference that regex record on a question field (for example, a catalog item variable).
- User input is validated in real time and on submit using the provided message.
Email Address Validation
Validates a single email address with common username and domain rules.
Regex
| |
Explanation Validates a single email by checking a safe local part, one @, and a dot-separated domain.
Validation Message Not a valid email
IPv4 Address Validation
Accepts valid IPv4 addresses only.
Regex
| |
Explanation Matches four dot-separated octets, each constrained to 0-255.
Validation Message Not a valid IPv4 address
IPv6 Address Validation
Accepts valid IPv6 addresses only.
Regex
| |
Explanation Matches standard IPv6 forms with optional compressed groups and embedded IPv4 where allowed.
Validation Message Not a valid IPv6 address
Network Share Name Validation
Allows letters, numbers, underscores, and hyphens with no spaces.
Network share names often include spaces or special characters that break scripts and automation. Apply this regex to allow only safe characters for share names and follow a consistent naming convention.
Regex
| |
Explanation Restricts to 1-80 characters and allows only letters, numbers, underscores, and hyphens.
Validation Message Must be 1-80 chars (A-Z, 0-9, _, -), no spaces or special characters
Phone Number Validation (US)
Validates 10-digit US phone numbers with optional country code and common separators.
Regex
| |
Explanation Allows optional country code, optional parentheses, and common separators for a 10-digit US number.
Validation Message Please enter a valid phone number
Phone Number Validation (International)
Validates international phone numbers with a required plus sign and country code.
Regex
| |
Explanation Requires a leading plus sign and country code, allows common separators, and limits the number to 7-15 digits.
Validation Message Enter number with + and country code, e.g. +1 555 123 4567
Server Name Validation
Enforces server naming with only letters, numbers, and hyphens. No leading or trailing hyphens.
Server names often drift from naming standards and introduce invalid characters or whitespace. Apply this question regex to standardize server names across catalog items and forms.
Regex
| |
Explanation Requires at least 3 characters, allows letters/numbers/hyphens, and blocks leading or trailing hyphens.
Validation Message Must be 3-15 chars (A-Z, 0-9, -), no leading/trailing hyphens or spaces
Note
This pattern enforces a minimum of 3 characters with no maximum. Change {3,} to {3,15} if you want a 15-character max. In my case the variable hasa “max_length=15” variable attribute that handles the max length, so I only enforce the minimum in the regex. Adjust as needed for your use case.
URL Validation
Matches URLs with http, https, ftp, or a leading www.
Regex
| |
Explanation Accepts URLs starting with a scheme or www, then matches common URL-safe characters.
Validation Message Not a valid URL
US Zip Code Validation
Accepts 5-digit ZIP codes and ZIP+4.
Regex
| |
Explanation Matches a 5-digit ZIP with an optional 4-digit extension.
Validation Message Incorrect zip code