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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    15,074
    Chris Langsenkamp
    Aug 20, 2003
  2. news.microsoft.com
    Replies:
    1
    Views:
    1,421
    Justin Martin
    Aug 10, 2003
  3. ronaldlee
    Replies:
    3
    Views:
    3,870
    Hans Kesting
    Dec 16, 2004
  4. Vijay
    Replies:
    1
    Views:
    3,700
    Martin Honnen
    Mar 22, 2005
  5. gk
    Replies:
    8
    Views:
    10,764
    Kent Paul Dolan
    May 24, 2006
  6. prashna

    What does this warning means?

    prashna, Sep 30, 2003, in forum: C Programming
    Replies:
    12
    Views:
    742
    goose
    Oct 2, 2003
  7. John

    what does JBOSS GA means?

    John, Aug 10, 2006, in forum: Java
    Replies:
    2
    Views:
    24,936
    Roland de Ruiter
    Aug 10, 2006
  8. Bruce Sam

    What does "void (*vector[])( )" means?

    Bruce Sam, Nov 13, 2004, in forum: C Programming
    Replies:
    7
    Views:
    473
    Barry Schwarz
    Nov 14, 2004
Loading...