# \[ask\]How to remove HTML part of a text

**URL:** <https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644>\
**Category:** Ruby\
**Created:** [December 25, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644 "2009-12-25T14:57:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inittial\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f1d935/32.png) [@inittial\_d](https://www.ruby-forum.com/u/inittial_d)\
**Post date:** [December 25, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644/1 "2009-12-25T14:57:56Z")

</div>

i’m using Hpricot to parsing html and my output is:

GrÃ¶ÃŸe: 37 - 54  
Maßtabelle

does anyone knows how to get the string “GrÃ¶ÃŸe: 37 - 54” and remove the  
rest of that string ?

thanks

---

<div class="post-metadata">

**Author:** ![inittial\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f1d935/32.png) [@inittial\_d](https://www.ruby-forum.com/u/inittial_d)\
**Post date:** [December 25, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644/2 "2009-12-25T16:13:39Z")

</div>

sorry for triple post…problem solved, i used nokogiri instead of  
hpricot 🙂

---

<div class="post-metadata">

**Author:** ![inittial\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f1d935/32.png) [@inittial\_d](https://www.ruby-forum.com/u/inittial_d)\
**Post date:** [December 25, 2009, 3:40pm UTC](https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644/3 "2009-12-25T15:40:07Z")

</div>

sorry for double posting, it seems there is no edit post feature…

I have a problem with HTML parsing issue. I’ll try to explain my problem  
as clear as I can, and I hope someone can help me with this.

I’ve been given a task to fetch a specific data from HTML page. I’m  
planning to use hpricot plugin to do this.  
It’s an online shop page, and I have to fetch cloth size information.

The product information part of the page can be in either of these 2  
formats:

 ... Some informations ... 

|
| |
| Available in: |
| ... (The data I want to fetch) ... |

OR

 ... Some informations ... 

|
| |
| ... Content ... | Available in: |
| ... Content ... | ... (The data I want to fetch) ... |

The clue is: The row whose data I want to fetch, is always preceeded by  
a row containing a string “Available in”.  
And I want to fetch NOT the content of the row, BUT the content of the  
last cell (

) contained inside the row.

It’s complex, and I have no idea on what to do here. Can someone help me  
with this?  
Thanks for the concern.

PS: The table snippet I post above may be contained inside another  
table.  
Apparently, the online shop use tables to do page formatting…

---

<div class="post-metadata">

**Author:** ![inittial\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f1d935/32.png) [@inittial\_d](https://www.ruby-forum.com/u/inittial_d)\
**Post date:** [December 26, 2009, 4:25am UTC](https://www.ruby-forum.com/t/ask-how-to-remove-html-part-of-a-text/180644/4 "2009-12-26T04:25:56Z")

</div>

Darmanto Lie wrote:

> thanks  
> “Gradhbbee: 37 - 54  
> ”[/^(._?)\</, 1]  
> ==\>“Gradhbbee: 37 - 54”  
> “Gradhbbee: 37 - 54  
> ”[/^(._?)(?=\<)/]  
> ==\>“Gradhbbee: 37 - 54”  
> “Gradhbbee: 37 - 54  
> ”[/^[^\<]\*/]  
> ==\>“Gradhbbee: 37 - 54”
