what does \s* means?

Discussion in 'Ruby' started by griffith Khana, Dec 15, 2009.

  1. what does the .\s* means in the following commad






    class String
    def sentences
    gsub(/\n|\r/, ' ').split(/\.\s*/)
    end
    end
    --
    Posted via http://www.ruby-forum.com/.
    griffith Khana, Dec 15, 2009
    #1
    1. Advertising

  2. \s* means occurrence of zero or more white spaces.

    gsub(/\n|\r/, ' ').split(/\.\s*/) is basically first removing all the line=
    feeds and carriage returns and then the sentence is split into an array wh=
    enever a dot followed by zero or more white spaces is encounterd.

    Regards,
    Raghav=20

    -----Original Message-----
    From: [mailto:]=20
    Sent: Tuesday, December 15, 2009 2:27 PM
    To: ruby-talk ML
    Subject: what does \s* means?




    what does the .\s* means in the following commad






    class String
    def sentences
    gsub(/\n|\r/, ' ').split(/\.\s*/)
    end
    end
    --=20
    Posted via http://www.ruby-forum.com/.
    Dasson, Raghav, Dec 15, 2009
    #2
    1. Advertising

  3. griffith Khana wrote:
    >
    >
    > what does the .\s* means in the following commad


    it's actually '\.\s*' => match a '.' followed by zero or more spaces

    read the regular-expression section for more details:

    http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_stdtypes.html


    >
    >
    >
    >
    >
    > class String
    > def sentences
    > gsub(/\n|\r/, ' ').split(/\.\s*/)
    > end
    > end



    --
    Kind Regards,
    Rajinder Yadav

    http://DevMentor.org

    Do Good! - Share Freely
    Rajinder Yadav, Dec 15, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rookie
    Replies:
    4
    Views:
    14,753
    Chris Langsenkamp
    Aug 20, 2003
  2. news.microsoft.com
    Replies:
    1
    Views:
    1,230
    Justin Martin
    Aug 10, 2003
  3. ronaldlee
    Replies:
    3
    Views:
    3,551
    Hans Kesting
    Dec 16, 2004
  4. Vijay
    Replies:
    1
    Views:
    3,104
    Martin Honnen
    Mar 22, 2005
  5. gk
    Replies:
    8
    Views:
    10,363
    Kent Paul Dolan
    May 24, 2006
Loading...

Share This Page