# Hpricot - parse html

**URL:** <https://www.ruby-forum.com/t/hpricot-parse-html/124824>\
**Category:** Ruby\
**Created:** [January 2, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/hpricot-parse-html/124824 "2008-01-02T22:13:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [January 2, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/hpricot-parse-html/124824/1 "2008-01-02T22:13:08Z")

</div>

hi @all

I would like to parse html code and remove all tags that starts with

How can I remove this tags with regex? I used the gsub! function to  
manipulate the string.

Thanks for helping…

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [January 3, 2008, 4:38am UTC](https://www.ruby-forum.com/t/hpricot-parse-html/124824/2 "2008-01-03T04:38:22Z")

</div>

Try this…

C:\temp\>irb  
irb(main):001:0\> mystring = “xxx yy zz”  
=\> “xxx yy zz”  
irb(main):002:0\> mystring.gsub(//,’’)  
=\> “xxx yy zz”

Regards,  
Jim

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [January 3, 2008, 11:37am UTC](https://www.ruby-forum.com/t/hpricot-parse-html/124824/3 "2008-01-03T11:37:39Z")

</div>

You should also process the \n, \r char.

So I think the regex should be “”.

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [January 3, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/hpricot-parse-html/124824/4 "2008-01-03T18:52:28Z")

</div>

On Jan 3, 2008 4:37 AM, sishen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You should also process the \n, \r char.
> 
> So I think the regex should be “”.

Don’t forget about the multiline option, it’s easy, just stick an ‘m’  
after the regexp.

Daniel Brumbaugh K.
