Split

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

<b>hi</b>, <b>there</b>, <b>fred</b>,

I would like to split them values into an array, Is there any chance
this can be done? Because im beginning to think there isn't

Tia

···

--
Posted via http://www.ruby-forum.com/.

Oh, i want all the values inside the <b></b> tags, btw

···

--
Posted via http://www.ruby-forum.com/.

"<b>hi</b>, <b>there</b>, <b>fred</b>,".scan(/<b>(.*?)<.b>/).
flatten
    ==>["hi", "there", "fred"]

"<b>hi</b>, <b>there</b>, <b>fred</b>,".
split(%r{<b>|</b>[, ]*(?:<b>)?})
    ==>["", "hi", "there", "fred"]

···

On Sep 16, 7:03 pm, Lee Jarvis <jarv...@gmail.com> wrote:

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

<b>hi</b>, <b>there</b>, <b>fred</b>,

I would like to split them values into an array, Is there any chance
this can be done? Because im beginning to think there isn't

Lee Jarvis wrote:

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

<b>hi</b>, <b>there</b>, <b>fred</b>,

I would like to split them values into an array, Is there any chance
this can be done? Because im beginning to think there isn't

Tia

There you go ---
f.split(/, |,/)

where f is your string.

···

--
Posted via http://www.ruby-forum.com/\.

Why won't your teacher let you use anything
other than split?

Does he know that you are getting your answers
from this forum?

···

On Sep 16, 7:03 pm, Lee Jarvis <jarv...@gmail.com> wrote:

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

<b>hi</b>, <b>there</b>, <b>fred</b>,

I would like to split them values into an array, Is there any chance
this can be done? Because im beginning to think there isn't

Oh, i want all the values inside the <b></b> tags, btw

str.split(/<b>|<\/b>,|<\/b>, <b>/)

Tia

--Greg

···

On Mon, Sep 17, 2007 at 09:03:52AM +0900, Lee Jarvis wrote:

Arindam Goswami wrote:

Lee Jarvis wrote:

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

<b>hi</b>, <b>there</b>, <b>fred</b>,

I would like to split them values into an array, Is there any chance
this can be done? Because im beginning to think there isn't

Tia

There you go ---
f.split(/, |,/)

where f is your string.

Thanks, but i need to values inside the <b> tags, So <b>hello</b> I need
hello..

···

--
Posted via http://www.ruby-forum.com/\.

William James wrote:

···

On Sep 16, 7:03 pm, Lee Jarvis <jarv...@gmail.com> wrote:

Ok guys im looking for something sexy to split this HTML (This HAS to be
done using split, nothing else)

Why won't your teacher let you use anything
other than split?

Does he know that you are getting your answers
from this forum?

Who said it was a teacher, This was for a challenge, And you're not
providing an answers, Just a very helpful solution..

Thank you all
--
Posted via http://www.ruby-forum.com/\.

Gregory Seidman wrote:

Oh, i want all the values inside the <b></b> tags, btw

str.split(/<b>|<\/b>,|<\/b>, <b>/)

I thought, among other attrocities, that < was a reserved character for regular expressions.

Not sure about the "has to be done using .split part", if some of us have studied REXML and Hpricot so thoroughly... (-;

···

--
  Phlip
  Test Driven Ajax (on Rails) [Book]
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax

Lee Jarvis wrote:

Thanks, but i need to values inside the <b> tags, So <b>hello</b> I need
hello..

Quick and dirty, but it works --

f.split(/, |,/).to_s.split(/<b>/).to_s.split(/<\/b>/)

could not figure out how to do this in one split

···

--
Posted via http://www.ruby-forum.com/\.

This one is better--

f.split(/<\/b>, <b>|<\/*b>,*/)

but it leaves you with one blank cell

···

--
Posted via http://www.ruby-forum.com/.