Inside a character range surrounded by [], the hyphen is interpreted
as defining a range, unless it's the first character. Move the
hyphens to the first character in the square brackets where it's
supposed to be interpreted as a hyphen.
Under PHP 7.3, the previous code failed with error message
preg_match(): Compilation failed: invalid range in character class at offset 7
// * Composed of alphanumeric chars, underscore and hyphens.
// * Maximum length of 64 chars.
// * Optionally surrounded by backticks, in which case spaces also OK.
- if (!preg_match('/^((`[\w- ]{1,64}`|[\w-]{1,64})\.)?(`[\w- ]{1,64}`|[\w-]{1,64})$/i', $str)) {
+ if (!preg_match('/^((`[-\w ]{1,64}`|[-\w]{1,64})\.)?(`[-\w ]{1,64}`|[-\w]{1,64})$/i', $str)) {
return FALSE;
}