[Wtr-general] How to pick the last word in the sentence
marekj
marekj.com at gmail.com
Thu Jul 12 02:02:44 EDT 2007
yes, you are right, much nicer to use the specific Array.last
It's so nice to call Array ring ring ring Hi Array give me your last element
please and Array responds.
marekj
On 7/10/07, Paul Rogers <paul.rogers at shaw.ca> wrote:
>
>
> I much prefer using
> words = sentences.split # or add (' ') to make split on whitespace
> explicit.
> last_word = words.last
>
>
> ----- Original Message -----
> From: marekj <marekj.com at gmail.com>
> Date: Tuesday, July 10, 2007 11:40 am
> Subject: Re: [Wtr-general] How to pick the last word in the sentence
> To: wtr-general at rubyforge.org
>
> > Hm...how about this:
> >
> > sentences =<<eof
> > some words and more words then some more words and the last one
> > word in a
> > sentence1.
> > Next sentence and more words and the last one word in a sentence2.
> > and here too
> > and then some more here
> > and last word of the last sentence.
> > eof
> > words = sentences.split # or add (' ') to make split on
> > whitespace explicit.
> > last_word = words[-1] #last element in Array is your last word
> > in a heredoc
> >
> > take a look at String.split goodness.
> > http://www.ruby-doc.org/core/classes/String.html#M000818
> >
> > marekj
> >
> >
> > On 7/9/07, sapna <forum-watir-users at openqa.org> wrote:
> > >
> > > Hi All,
> > >
> > > Pleas can you help me finding out the last word in the
> > sentence displayed
> > > on the web page. Have look at the HTML snippet.
> > >
> > > Regards
> > > Sapna
> > > _______________________________________________
> > > Wtr-general mailing list
> > > Wtr-general at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/wtr-general
> > >
> >
>
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070712/65b778e9/attachment-0001.html
More information about the Wtr-general
mailing list