A
A
Alexey2016-02-06 00:20:39
PHP
Alexey, 2016-02-06 00:20:39

Why does an error appear in the regular expression when there is a space?

Hello! Literally for no reason, without changing anything in the code, the regular expression stopped working . It gives
the following error:
E_WARNING : type 2 -- preg_match(): Compilation failed: range out of order in character class at offset 19

preg_match("/^[A-zА-яёЁ0-9_-\s]{3,50}$/iu", 'Морковь');

I experimentally found out that this is due to a space in the template, but no matter how I add " " or "\s", the error does not disappear.
Therefore, two questions, what could cause the error to appear (the code did not change, but worked before) and what kind of error is this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-02-06
@dzheka3d

^[\w\s-_]{3,50}$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question