Hi all,
I'm just wonderinf if someone could explain simply how the heck these things work.
I'm just trying to split a string on either a space or a comma, so I look up help on preg_split, but I cant make heads or tails of how the pattern relates to what it is supposed to find.
For example, it says that a pattern of '/[\s,]+/' is going to find 'commas or space characters which include " ".'
Whaaa?!?
Please ... can anyone help me understand this. I've come across it before in a few other functions and I just cant seem to find any info on what it all means.
Thanks
I dont get it - preg_split patterns?
Moderator: General Moderators
RegEx are the evil dragon in the realm of programming. But once you've got to know them a bit, they are extremely powerful (bit like a dragon).
There are plenty of tutorials about, just google for them - I remember I found one on phpbuilder.com quite useful.
Regarding the patterns itself - have a look at "Pattern Syntax" in the manual: http://uk.php.net/pcre.pattern.syntax
\s means any whitespace character, btw.
There are plenty of tutorials about, just google for them - I remember I found one on phpbuilder.com quite useful.
Regarding the patterns itself - have a look at "Pattern Syntax" in the manual: http://uk.php.net/pcre.pattern.syntax
\s means any whitespace character, btw.