On Mon, Mar 1, 2010 at 9:50 AM, [email protected] < [email protected]> wrote:
> I am trying to split some text into an array seperated by one or more > <br> > > Here is some test code: > > s = "one<br>two<br><br>three<br><br><br>four" > p s.split(/(<br>)+/); > > it should split into ["one","two","three","four"] because the / > (<br>)+/ pattern should use one or more <br> as the pattern to split > around > > but it does this > ["one", "<br>", "two", "<br>", "three"] > > Why does it do this and what split could I use to get it to work? > > Note:, I know that I could just fix it by removeing the <br> lines > after it is done from the array, but it seems that the regular > expression in split should work. > > Gerry, you can do the following: p s.gsub(/<br>/, " " ).split Good luck, -Conrad > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

