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 " , ".
This returns
117/1 Main St ,(with space and comma):And this returns
117/1 Main St(space and comma removed):