Answer the question
In order to leave comments, you need to log in
What's wrong with regex?
Good evening. I'm trying to split a string with a regular expression. Everything is fine here:
$keywords = preg_split("/[\s,]+/", "hypertext language, programming");
print_r($keywords); // Array([0] => hypertext [1] => language [2] => programming)
$keywords = preg_split("/^[^)]+/", "hypertext) language), programming");
print_r($keywords); // Array ( [0] => [1] => ) language), programming )
//хотя я ожидаю увидеть Array ( [0] => hypertext [1] => ) language), programming )
Answer the question
In order to leave comments, you need to log in
you won't succeed
because you start eating
you should understand what preg_split
does -
it splits a string according to a regular expression.
if we have a regular expression ^[^)]+
"bites" this part:
then you will get the result:Array ( [0] => [1] => ) language), programming )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question