Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:50:33+00:00 2026-05-29T09:50:33+00:00

Here is an excerpt from the html I want to scan through. <div class=text>

  • 0

Here is an excerpt from the html I want to scan through.

<div class="text">
 <h3>
  <a href="http://www.faith.co.uk/">
   Rodeo Sinclair
  </a>
 </h3>

And here is my ruby code.

@doc = open(url) { |f| 
  @doc = f.read
}

output = @doc.scan(/<h3><a href=(.*?)>/) 

This does not work because of the new lines and spaces in the html file. Is there anyway I can get around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:50:34+00:00Added an answer on May 29, 2026 at 9:50 am

    I could easily create a regular expression that would parse your HTML fragment.

    However, I would like to encourage you to get in the habit of using an XML/HTML parser to interact with HTML.

    require 'nokogiri'
    require 'open-uri'
    
    doc = Nokogiri::HTML(open(url))
    
    output = doc.css('div h3 a').each do |link|
        puts link.attr("href")
    end
    

    See RegEx match open tags except XHTML self-contained tags for a compelling argument against using regular expressions to parse HTML.

    ==EDIT== changed to an each loop

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a puzzle. Basic page, one element: http://jsfiddle.net/PZj6t/ HTML: <div id=container></div>​ CSS: body, html
Here's an excerpt from Live HTTP headers, I've replaced several values for anonymity. POST
Here's an excerpt from a book I'm reading about application design with MVC: Ideally,
Here's an excerpt from Sun's Java tutorials : A switch works with the byte
What did I do wrong? Here is an excerpt from my code: public void
Here is a code excerpt from AspComet project that works with Autofac. public MessageBus(IClientRepository
I have a DIV which I want to insert into my HTML content. Whenever
I want to know how can i send a <FORM> from a html pages
I have picked a snippet from http://docs.python.org/library/multiprocessing.html#multiprocessing-examples import multiprocessing def queue_func(queue): for i in
I want to perform some simple form validation in my controller. Here's an excerpt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.