Sign in to follow this  
Followers 0
Roel

Help with RegEx asked

3 posts in this topic

Hi,

I would like some help with my Reg Ex:

(?i)(?x)\<div\sclass=\"detail\"\>\<div\sclass\=\"detail\-label\"\>(.*\)<\/div\>\<div\sclass\=\"detail\-value\"\>.*\<\/div\>\<div\sclass\=\"clear\"\>\<\/div\>\<\/div\>

I get everything between the beginning and the end of the string. It should be in an array with all the repeating matching tags. A little bit difficult to explain in eglish Please try :-)

Help would be appreciated.

Roel

This is the HTML:

<div id="admintabcontent">
                            
                                <div class="detail"><div class="detail-label">Service-ID</div><div class="detail-value">1074992</div><div class="clear"></div></div><div class="detail"><div class="detail-label">VPN Naam</div><div class="detail-value">wea</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Organisatie</div><div class="detail-value">WA-It BV, INTERNAL-1-1KUJH</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Straatnaam Epa</div><div class="detail-value">Keizer Karelplein</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Huisnr.</div><div class="detail-value">24</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Toev. Huisnr.</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">Stad</div><div class="detail-value">Sas van Gent</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Postcode.</div><div class="detail-value">4551CJ</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Rayon</div><div class="detail-value">RZW</div><div class="clear"></div></div><div class="detail"><div class="detail-label">ContactPersoon</div><div class="detail-value">DHR J van Hees</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Telefoonnummer</div><div class="detail-value">+310113256345</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Productnaam</div><div class="detail-value"></div><div class="clear"></div></div><div class="expand"><div class="expand-button">[+]</div><div class="expand-title"><div class="detail"><div class="detail-label">Network info Epacity-ID</div><div class="detail-value">1074992</div><div class="clear"></div></div></div><div class="expand-body" style="display: none;"><div class="detail"><div class="detail-label">Servicetype</div><div class="detail-value">xDSL 1024/1024 1:1</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Vrftag</div><div class="detail-value">wea-5335</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Netwerknaam</div><div class="detail-value">wea</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Router</div><div class="detail-value">nl-rt-dc2-vpn-10ker02</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Physieke poort</div><div class="detail-value">nl-rt-dc2-vpn-10ker02-3-0-1</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Logische poort</div><div class="detail-value">EPAC/118</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Logische Pvc</div><div class="detail-value">1/399</div><div class="clear"></div></div><div class="detail"><div class="detail-label">VPN Poort Profiel</div><div class="detail-value">xDSL.PPP.num</div><div class="clear"></div></div><div class="detail"><div class="detail-label">NAS Identifier</div><div class="detail-value">213.162.172.76</div><div class="clear"></div></div><div class="detail"><div class="detail-label">NAS Poort ID</div><div class="detail-value">822149519</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Address Tag</div><div class="detail-value">172.16.52.2</div><div class="clear"></div></div><div class="detail"><div class="detail-label">IP Adres</div><div class="detail-value">172.16.52.1</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Statische routes</div><div class="detail-value">10.52.0.0 255.255.0.0</div><div class="clear"></div></div><div class="detail"><div class="detail-label">QoS Policy</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">Encapsulation</div><div class="detail-value">PPPoA</div><div class="clear"></div></div><div class="detail"><div class="detail-label">ATM Service</div><div class="detail-value">vbr</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Ap Line-ID</div><div class="detail-value">EPAC/118-EAP/422633/2</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Create Data</div><div class="detail-value">05/10/2007 02:30</div><div class="clear"></div></div><div class="detail"><div class="detail-label">VLan Nummer</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">Ethernet Class</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">BGP</div><div class="detail-value">On VPN level disabled</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Xdsl Type</div><div class="detail-value">SDSL</div><div class="clear"></div></div><div class="detail"><div class="detail-label">VPN Type</div><div class="detail-value">Epacity SDSL 1024 1024 1:1</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Centralsite</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">Provider ID</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">Line ID</div><div class="detail-value"></div><div class="clear"></div></div><div class="detail"><div class="detail-label">SLA Epacity</div><div class="detail-value">Service Level Kantoor (ADSL/SDSL)</div><div class="clear"></div></div><div class="detail"><div class="detail-label">Router Type</div><div class="detail-value"></div><div class="clear"></div></div></div></div><div class="expand"><div class="expand-button">[+]</div><div class="expand-title"><p>Opmerkingen</p></div><div class="expand-body" style="display: none;"><div class="detail"><div class="detail-label"></div><div class="detail-value"></div><div class="clear"></div></div></div></div>                           
                            
                                                        
                        </div>

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

(?i)(?x)\<div\sclass=\"detail\"\>\<div\sclass\=\"detail\-label\"\>(.*\)<\/div\>\<div\sclass\=\"detail\-value\"\>.*\<\/div\>\<div\sclass\=\"clear\"\>\<\/div\>\<\/div\>

I guess you can make it much cleaner, you don't need to escape almost everything.

'(?i)(?x)<div\sclass="detail"><div\sclass="detail-label">(.*?)</div><div\sclass="detail-value">.*?</div><div\sclass="clear"></div></div>'

Note the lazy quantifiers .*?, very important, it may or may not march matching anything up to the end of the line, and may backtrack to a satisfying position which may not be what you want.

Edited by Authenticity

Share this post


Link to post
Share on other sites

Hi,

Thanks for the RegEx, it works just fine!

Roel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0