preg split

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Thompson

    #1

    preg split

    Hi All,

    Trying to split a string where there are occurances of a space, a comma, a
    newline (char 10), or a return (char 13) using the preg_split function, but
    not sure how to write the regular expression for this...

    Anyone any idea please?

    Thanks,
    Chris.



  • pritaeas

    #2
    Re: preg split

    $result = preg_split ('/ |,|\n/', $subject);

    "Chris Thompson" <c.thompson@zen .co.ukwrote in message
    news:44c743dc$0 $15048$db0fefd9 @news.zen.co.uk ...
    Hi All,
    >
    Trying to split a string where there are occurances of a space, a comma, a
    newline (char 10), or a return (char 13) using the preg_split function,
    but not sure how to write the regular expression for this...


    --
    Posted via a free Usenet account from http://www.teranews.com

    Comment

    • Alvaro G. Vicario

      #3
      Re: preg split

      *** Chris Thompson escribió/wrote (Wed, 26 Jul 2006 11:28:38 +0100):
      Trying to split a string where there are occurances of a space, a comma, a
      newline (char 10), or a return (char 13) using the preg_split function, but
      not sure how to write the regular expression for this...
      Not tested:

      '/[\s,]+/'


      --
      -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
      ++ Mi sitio sobre programación web: http://bits.demogracia.com
      +- Mi web de humor con rayos UVA: http://www.demogracia.com
      --

      Comment

      Working...