On Fri, Sep 14, 2012 at 10:00 AM, Joel Pearson <[email protected]> wrote: > The quick way to do that would be: > > "tes<tr>ubyrails <[email protected]>".split(" <").each do |el| puts > el[0..-2] end > > If you wanted something a bit more flexible I recommend regex.
Like irb(main):001:0> s = 'tes<tr>ubyrails <[email protected]>' irb(main):002:0> if %r{\A(.*?)\s+(<.*?>)\z} =~ s then front=$1; rear=$2; p front, rear; end "tes<tr>ubyrails" "<[email protected]>" => ["tes<tr>ubyrails", "<[email protected]>"] > Do you have more examples, or is this static data you're using? That would certainly be helpful. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google 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 https://groups.google.com/d/forum/ruby-talk-google?hl=en
