Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

RegEx: Get Values from HTML Attribute Tags

$
0
0
I need to get the values from below following html snippet. So far I came up with this regex which helps me trim it down to the values I needed, but to automate this I need to join 2 regex statements to get the result "18" which is where I am stuck at. Or Please suggest a better method for me get the values.

I am using WebHarvey scraping tool. The program is based on .net but it doesn't support inserting .net code so I need only regex command.

First Regex Statement
(?s)(?<=attribute bathroom).+?(?=\/span)
Result:
" title="Bathrooms" style="  "><span class="value" style="  ">18<


Second Regex Statement
(?s)(?<=<span class="value" style=" ">).+?(?=<)
Result: 18

HTML Snippet

<ul class="iconContainer" style="  "><li class="attribute propertyId">
                    xxx1</li><li class="attribute propertyType">
                    Factory</li><li class="attribute bathroom" title="Bathrooms" style="  ">
                    18</li><li class="attribute carspace" title="Car Spaces" style="  ">
                    18</li><li class="attribute landArea"><span title="Land Area">
                            5,010<span class="unit">m2</span></span><span>|</span><span title="Floor Area">
                            9,270<span class="unit">m2</span></span></li></ul>

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>