# Help with regex needed

**URL:** <https://www.ruby-forum.com/t/help-with-regex-needed/151493>\
**Category:** Rails\
**Created:** [October 22, 2008, 7:06am UTC](https://www.ruby-forum.com/t/help-with-regex-needed/151493 "2008-10-22T07:06:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [October 22, 2008, 7:06am UTC](https://www.ruby-forum.com/t/help-with-regex-needed/151493/1 "2008-10-22T07:06:29Z")

</div>

Hi here is the array I am scanning:  
["\n

&nbsp;\<a href="/search~S13?/rWR%20121/rwr+121/1,7,9,B/  
frameset~2489041&FF=rwr+121&1,1,"\>The Academic Writer: A Brief Guide\</  
a\>\n\n\n&nbsp;Ede, Lisa\n\n\n\n&nbsp;Valley  
Reserves – VR 282 – AVAILABLE\n\n\n\n&nbsp;\n\n\n\</  
tr\>\n\n&nbsp;\<a href="/search~S13?/rWR%20121/rwr+121/1,7,9,B/  
frameset~1334646&FF=rwr+121&1,1,"\>Cultural literacy : what every  
American needs to know / E.D. Hirsch, Jr. ; with an appendix, What li\</  
a\>\n\n\n&nbsp;Hirsch, E. D. (Eric Donald), 1928-\n\n  
\n\n&nbsp;Valley Reserves – LC149 .H57 1987 – AVAILABLE\n  
\n\n\n&nbsp;\n]

I am trying to pull out the essential (everything but the newlines and  
such) value in between the

.

Here is the regex I am trying:  
s.first.scan(/\<td \>(.\*?)\</td\>/mi)  
But I don’t get the first

 a href value.

Any help would be appreciated. Kim

---

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [October 22, 2008, 7:11am UTC](https://www.ruby-forum.com/t/help-with-regex-needed/151493/2 "2008-10-22T07:11:45Z")

</div>

Use hpricot plugin to handle HTML parsing.

---

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [October 22, 2008, 3:27pm UTC](https://www.ruby-forum.com/t/help-with-regex-needed/151493/3 "2008-10-22T15:27:06Z")

</div>

On Oct 22, 12:14 am, Kim [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \n\n\n&nbsp;\n]
> 
> I am trying to pull out the essential (everything but the newlines and  
> such) value in between the .

I agree with Mukund. Use Hpricot:

html = Hpricot(s.first)

html.search( “td” ) do |cell|  
puts cell.inner\_html  
end

– Mark.
