From: Josh Cheek Date: 2011-08-11T07:34:54+09:00 Subject: Re: Reg Ex Help Required --0016e646047081110604aa2e49c2 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Aug 10, 2011 at 1:30 PM, Chris White wrote: > > On Aug 10, 2011, at 11:20 AM, saurabh a. wrote: > > > Hi, > > > > Please help me with regular expression. > > > > str = "abc = 100.300" > > > > i want to write a regular xpression for getting the value after =, i.e. > > 100.300, i mean reg ex should return value after = > > Might I suggest an alternative to regex? > > irb(main):003:0> str.split(/ = /) > => ["abc", "100.300"] > irb(main):004:0> str.split(/ = /)[1] > => "100.300" > irb(main):005:0> > > Regards, > Chris White > http://www.twitter.com/cwgem > > I'd use split as well, but I'd probably do it like this: str = "abc = 100.300" variable, value = str.split('=', 2).map(&:strip) variable # => "abc" value # => "100.300" --0016e646047081110604aa2e49c2--