match substring of a source code in ruby
I'd like to isolate a substring of a source code in ruby, but I can't have better than this http://rubular.com/r/ALngW9TOwy I'd like to stop my match at the end of the first
<p>[...]/n</p>
I tried some things, but I have to admit that I suck at regex. I know there's a lot of method, like using Regexp or a simple regex, but I'm lost. If somebody can help, it would be great ! Thanks a lot !
EDIT: Thanks to Mchl, I ha开发者_StackOverflow中文版ve the solution. I put my need in the commentary, but it'll be better here: so I use this
match(/<p>(.*?)<\/p>/m)[1].strip
Not sure if I inderstood correctly, but it seems to me, you need to 'ungreed' the *
<p>(.*?)<\/p>
you should try negative lookahead
<p>((.(?!<\/p>))*.)<\/p>
精彩评论