preg_split()......!

Discussion in 'PHP' started by strgraphics, Jun 22, 2010.

  1. #1
    Hello Firends..,

    every day i thought that i have know some thing about preg_split(), but when ever i am trying to applying, i am facing some doubts and problems..

    please.., help me!


    where i can learn about preg_split(), i mean dont give http://php.net/, i already visited not understand clearly..., i mean my intension is to understand..

    
    example:
    preg_split("/[\s]+/", $stri
    
    PHP:
    using / / for starting and ending., and what about that /s and [/s] and some other symblos tooooo.,

    Please explain or share any site if you know, which gives the clear explanation for it..
    even in famous sites also i checked but they are not clear..!

    I would be most great ful for your time and help..!

    Thanks
    Jaswanth
     
    strgraphics, Jun 22, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Im not sure why you arent looking at http://www.php.net; it has /everything/ you need on there. If more people paid attention to it, there wouldn't be so many myths flying around :(

    The slashes are used as delimeters; /(content)/ is showing the start and end of the expression (content). You dont have to use slashes, you can use anything you like (there are rules to it, see the link below) as long as they match.

    With regards to the rest, it is a regular expression; you might want to read up on that as it isnt independant to the split function;

    *EVERYTHING* you need to know to answer your query is here including delimeters, and all other characters, you shouldnt be so quick to discard the OFFICIAL website.

    http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
    http://uk.php.net/manual/en/regexp.reference.meta.php

    There are plenty of other places around; google if you need more.

    http://www.regextester.com/pregsyntax.html
     
    lukeg32, Jun 22, 2010 IP
  3. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    ya i read in php.net.., but friend..
    there i not found clear explanation like why /s /w... like those.. that why.. am asking hear..!

    Any way thanks yar.
     
    strgraphics, Jun 22, 2010 IP
  4. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #4
    from one of the links I included above, there is a link for "backslashes"

    http://www.php.net/manual/en/regexp.reference.backslash.php

    Here you can find your answer:

    It's all there :)
     
    lukeg32, Jun 22, 2010 IP
  5. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #5
    probably, like lukeg32 said, you dont need reference on preg_split, or preg_match or any of the PCRE functions

    you need reference on PCRE syntax itself... its a bible out there at php.net
    refer http://www.php.net/manual/en/pcre.pattern.php
    and i would suggest you start reading with syntax http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
     
    bvraghav, Jun 22, 2010 IP
  6. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Ya finally i got.., thanks a lot lukeg32, and bvraghav.
     
    strgraphics, Jun 22, 2010 IP