From: "Jesús Gabriel y Galán" Date: 2012-06-27T16:35:59+09:00 Subject: Re: help for a little regexp On Wed, Jun 27, 2012 at 9:24 AM, Quentin R-G wrote: > Hi everyone, > > So I am new to ruby, and I need help for a regexp. > I want to stock the letter and the number in this sting "e = 11.1607" > > I tried with this regexp: > > /(?^\w+)\/(?\d{1,2}.\d+)/ > > But it does not match anything... But I tried separatly and it returns > me the good things. I do not understand what's the problem ^^' > > Thank you to everyone who gonna help me ! :) This works for me. Note that the start anchor "^" is outside of the group, and that between both groups you need to match spaces and "=". Also the "." has to be escaped to be matched exactly, otherwise it's any character: 1.9.2p290 :026 > m = string.match /^(?\w+)\s*=\s*(?\d{1,2}\.\d+)/ => # 1.9.2p290 :030 > m.names => ["letter", "frequency"] 1.9.2p290 :031 > m["letter"] => "e" 1.9.2p290 :032 > m["frequency"] => "11.1607" Jesus.