开发者

php preg_split functionality

开发者 https://www.devze.com 2023-01-13 04:04 出处:网络
is there a way to understand the following logic contained in the splitting pattern: preg_split(\"/[\\s,]+/\", \"hypertext language, programming\");

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开发者_Python百科 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.


+ 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号