Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > what does \s* means?

Reply
Thread Tools

what does \s* means?

 
 
griffith Khana
Guest
Posts: n/a
 
      12-15-2009



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

 
Reply With Quote
 
 
 
 
Dasson, Raghav
Guest
Posts: n/a
 
      12-15-2009
\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: [private.php?do=newpm&u=]=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/.


 
Reply With Quote
 
 
 
 
Rajinder Yadav
Guest
Posts: n/a
 
      12-15-2009
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/Program..._stdtypes.html


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



--
Kind Regards,
Rajinder Yadav

http://DevMentor.org

Do Good! - Share Freely

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET 2.0 ASPx Page does not load, but HTM does prabhupr@hotmail.com ASP .Net 1 02-08-2006 12:57 PM
Button OnClick does not fire on first postback, but does on second Janet Collins ASP .Net 0 01-13-2006 10:08 PM
Does the 2.0 Framework come out when Visual Studio .NET 2005 does? needin4mation@gmail.com ASP .Net 3 10-07-2005 12:55 AM
CS0234 Global does not exist ... but it genuinely does Bill Johnson ASP .Net 0 07-08-2005 06:34 PM
Does no one else think microsoft does a poor job? =?Utf-8?B?SmVyZW15IEx1bmRncmVu?= Wireless Networking 2 11-20-2004 12:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57