You need to escape dashes when using them inside of character classes:
'/[[([A-Za-z0-9_\-\s])]]:(.?):([10]*)/'
Quoting from this answer by Konrad Rudolph:
The hyphen is usually a normal character in regular expressions. Only if it’s in a group expression and between two other characters does it take a special meaning.
The crux of the issue is that the regular expression is believing that this part of the character class: _-\s
is denoting a character range (like as in [A-Z]
or [a-z]
) which is invalid, hence the error.
The regex engine does not treat the hyphen as part of a character range if it is included at either the beginning or end of the character class, so both of these would also work for you:
'/[[([A-Za-z0-9_\s-])]]:(.?):([10]*)/'
'/[[([-A-Za-z0-9_\s])]]:(.?):([10]*)/'