--------------030408030306020303060208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit suroot57 / gmail.com wrote: > On Sep 22, 12:58 pm, Cheyne Li <happy.go.lucky.... / gmail.com> wrote: > >> Hi experts, >> >> I'm not very familiar with ruby's library. I wonder if there a method >> can extract something in a pattern? For example, >> >> I have a string: abcc<p>ccddee</p> >> >> I wanna get the anything between <p> and </p>, which is ccddee >> >> Thanks in advance. >> -- >> Posted viahttp://www.ruby-forum.com/. >> > > If you want to use regexp, a quick and dirty way would be : > > (a.split %r{</?p>})[1] > or: irb(main):001:0> a aabbcc<p>ccddee</p>' "aabbcc<p>ccddee</p>" irb(main):002:0> a[%r{<p>(.*)</p>}, 1] "ccddee" > -- Ittay Dror <ittayd / tikalk.com> Tikal <http://www.tikalk.com> Tikal Project <http://tikal.sourceforge.net> -- -- Ittay Dror <ittay.dror / gmail.com> --------------030408030306020303060208--