Reputation: 3095
Hi friend~
I want get the content between the first html tag and the second html tag.
for example
<p>Hello <bold>world</bold>!</p>
will return
Hello
What should I do in Ruby?
Thank you~
Upvotes: 3
Views: 1438
Reputation: 300
Regex will be: <[^>]*>([^<]*)
<[^>]*>
- math thiw first tag "<...>"([^<]*)
- capture text to open next tag "<...> some text <...>"how apply him on Rubby - i dont know
look http://www.regular-expressions.info/ruby.html
Upvotes: 4
Reputation: 25593
A regular expression catching everthing between the first and the second pair of angle brackets lools like
/<.*?>(.*?)</m
The result will be in the first capturing group of the first match.
Note that this will probably fail on HTML comments and JavaScript.
Upvotes: 0