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

  • Home
  • SEARCH
  • 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 8279891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:28:37+00:00 2026-06-08T09:28:37+00:00

Using Nokogiri and Ruby, I am trying to parse out a street address using

  • 0

Using Nokogiri and Ruby, I am trying to parse out a street address using a CSS selector. However, it is also including the city which I do not want.

Here is the statement I am using:

address = listing.at_css(".address").text

Here is the HTML:

<div class="address">
  117/1 Main St ,
  <span class="green">
  <strong>
   <u>
    <a href="city">Chicago</a>
   </u>
  </strong>
  </span>

The result I want:

117/1 Main St

but the result I am getting:

117/1 Main St , Chicago \n

I was thinking of using regex in combination with Nokogiri, but I’m not sure if Ruby can cut everything out after " ," including going back to cut out the " , ".

  • 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-06-08T09:28:39+00:00Added an answer on June 8, 2026 at 9:28 am

    This returns 117/1 Main St , (with space and comma):

    listing.at_css(".address").child.text
    

    And this returns 117/1 Main St (space and comma removed):

    listing.at_css(".address").child.text.sub(/ ,$/,"")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse XML files using Nokogiri, Ruby and XPath. I usually
I am trying to parse a bunch of XML files. I am using Nokogiri,
Using Nokogiri and Ruby. I have a page to parse with div id's like:
I'm trying to use Ruby's Nokogiri to parse large (1 GB or more) XML
I'm trying to write a script in Ruby to parse a Wikipedia article using
If I want to parse a HTML block using Nokogiri in Ruby like this:
I am trying to read an XSD file using Nokogiri Ruby parser and it
I'm using Ruby and Nokogiri to parse HTML documents, and I would like to
I have trouble parsing a HTML table using Nokogiri and Ruby. My HTML table
I'm using Nokogiri to parse an XML response from last.fm. I am currently returning

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.