From: Jennifer Lee Date: 2010-06-17T00:34:45+09:00 Subject: Re: split doesn't work Brian Candler wrote: > Firstly, I suggest you write this as a standalone ruby program without > erb, so it's easy to debug. Secondly, add debugging print statements to > show what the variables are doing at each stage. > > Your code uses both @def and @def_str, so I'm having to guess what > you're trying to do, but I imagine something like this: > > @terms = %w(cuddly soft cute) > @def_str = "teddy bears are cuddly stuffed animals which are generally > soft and given to cute children" > @def = @def_str > @terms.each do |term| > regex = Regexp.new(/#{term}/) > matchdata = regex.match(@def_str) > if matchdata > puts "Match!" > puts "Before: @def = #{@def.inspect}" Thanks for your help Brian I figured out that I was telling def to split, but I forgot to make sure it was returned to string form after the first split. :-) -- Posted via http://www.ruby-forum.com/.