views:

41

answers:

2

hello,

is there a way to understand the following logic contained in the splitting pattern:
preg_split("/[\s,]+/", "hypertext language, programming");

in the grand scheme of things i understand what it is doing, but i really want a granular understand of how to use the escapes and special character notation. is there a granular explanation of this anywhere? if not could someone please provide a breakdown of how this works. it is something very useful, and something i would like to have completely under in my belt so to speak.

A: 

you should have a look at regular expressions, this might be a good place to start http://www.regular-expressions.info/reference.html

Silfverstrom
A: 
+ means 1 or more

[\s,] means a space and/or comma character

This will split the text by 1 or more spaces and commas together

definitely read http://www.regular-expressions.info/ as Silfverstrom recommended. Also what helped me learn was this game: http://www.javaregex.com/agame.html

Galen