php - Get part of the regex -
I am trying to parse an HTML page and get a specific data (with PHP). This is my regex:
$ pattern = '/ class = \ "group \" & gt; * [\ N \ r] *. * [\ N \ r] *. * [\ N \ r] * * / '. Preg_match_all ($ patterns, $ theme, $ match); And that's what I'm getting (highlighted in yellow):
& lt; NOBR & gt; × ?? × ?? × × × × × × ×? And × × ?? × × ?? × ?? & Lt; Input type = "checkbox" name = "DEL104004" onClick = "UPG104004.selectedIndex = 0" & gt; & Lt; / NOBR & gt; & Lt; / TD> & Lt; TD class = "group" & gt; 22 & lt; / TD> & Lt; TD class = "points" & gt; 5.0 & lt; / TD> & Lt; TD & gt; Some text & lt; / TD> & Lt; TD & gt; AL HEIF = "http://www.website.com/mk.php?MK=104004" class = "mk" & gt; 104004 & lt; / A & gt; & Lt; / TD> & Lt; / TR & gt; & Lt; TR ALIGN = Wright BGCOLOR = # FFCC 33> & Lt; TD colon = 2> & Lt; BR & gt; & Lt; / TD> & Lt; TD & gt; 5.0 & lt; / TD & gt; But in fact everyone needs data which is spread in red (22, 104004). Can I do it with a regex?
More info I think this special structure will not change. HTML is a table with mostly a few lines, some of them want to get data (group number and Mk number).
Your updated information ( ... the data I want to receive (group Number and mk number) ), you can do just one with XPath: $ dom = new DOMDocument ("1.0", "UTF-8"); $ Dom- & gt; LoadHTML ($ HTML); $ Xpath = new DOMXPath ($ dom); Forex Currency ($ xpath- & gt; Query ('// td [@ class = "group' 'or @ class =" mk "]) as $ node {echo $ node- & gt; Features-> getNamedItem ("class") - & gt; NodeValue; / * Class name * / echo ":"; Echo $ node-> Text content; / * Data * / resonance "\ n"; }
No line-break / line number traps.
Comments
Post a Comment