Re: [Wtr-general] How to pick the last word in the sentence

2007-07-11 Thread marekj

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 <[EMAIL PROTECTED]> wrote:



I much prefer using
words = sentences.split # or add (' ') to make split on whitespace
explicit.
last_word = words.last


- Original Message -
From: marekj <[EMAIL PROTECTED]>
Date: Tuesday, July 10, 2007 11:40 am
Subject: Re: [Wtr-general] How to pick the last word in the sentence
To: [email protected]

> Hm...how about this:
>
> sentences =< 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 <[EMAIL PROTECTED]> 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
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>

___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to pick the last word in the sentence

2007-07-10 Thread Paul Rogers

I much prefer using
words = sentences.split # or add (' ') to make split on whitespace explicit.
last_word = words.last


- Original Message -
From: marekj <[EMAIL PROTECTED]>
Date: Tuesday, July 10, 2007 11:40 am
Subject: Re: [Wtr-general] How to pick the last word in the sentence
To: [email protected]

> Hm...how about this:
> 
> sentences =< 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 <[EMAIL PROTECTED]> 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
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> 
___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to pick the last word in the sentence

2007-07-10 Thread marekj

Hm...how about this:

sentences = 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
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to pick the last word in the sentence

2007-07-10 Thread Chong
str = "What was your first pet's name?Another sentence here"
sentences = str.scan(/([^<]*)/)
last_words_arr = []
for arr in sentences
  sentence = arr.first
  sentence.gsub!('?', '')
  sentence.gsub!('.', '')
  sentence.gsub!('!', '')
  last_word = sentence.split.last
  last_words_arr << last_word
end
p last_words_arr
___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How to pick the last word in the sentence (sapna)

2007-07-10 Thread Ajitesh Srinetra

Hi Sapna,

The HTML code was not there , But you can try this

string=ie.link(:id,'yourlink'sID').text
mytext=string.split('  ') #Separated by space
yourtext=mytext[mytext.length - 1]

For more help you can refer array class in ruby
Let me know if it is helpful

Ajitesh
___
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] How to pick the last word in the sentence

2007-07-09 Thread sapna
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
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general