From: Xavier Noria Date: 2008-03-17T05:17:33+09:00 Subject: Re: returning text between two markers without markers included On Mar 16, 2008, at 21:02 , Adam Akhtar wrote: > > Hi if have > > str = "ruby is ((Great))" > > how do i use regex to find text between the start marker (( and end > marker ))? > > Im new to regex but I tried this > > \(\(([^((|^))]*)\)\) > > but it includes the markers in the capture i.e. it gives ((Great)) > when > i just want Great. The fact that the parens are delimiters obscures the regexp a bit. Assuming "))" ends the text to extract unconditionally you can simply use .*? like this irb(main):001:0> "ruby is ((Great))".match(/ \(\( (.*?) \)\) /mx)[1] => "Great" -- fxn