Matt Brooks wrote: > say original string is "CHLE,231,1", and i receive string I want to > check against it. > > I guess you could say the strings are comma separated within each string > that I receive. > > I need to know it matched if I receive "CHLE,231" or "CHLE,231,1" but if > I get "CHLE,23" or "CHLE,231,2" these should not be matches, and should > say nil. blah = "CHLE,231,1" incoming = "CHLE,231,1" blah[/\A#{incoming}(\z|,)/] incoming = "CHLE,231" blah[/\A#{incoming}(\z|,)/] incoming = "CHLE,232" blah[/\A#{incoming}(\z|,)/] incoming = "CHLE,231,2" blah[/\A#{incoming}(\z|,)/] incoming = "CHLE,23" blah[/\A#{incoming}(\z|,)/] (The result of the match sometimes include a trailing comma, but that won't matter if it's just the match or no-match you require) -- Posted via http://www.ruby-forum.com/.