I know My question seems Like duplicated(duplicate)…
But exceptionally I’m not trying to parse a “True/Valid” HTML, its a part of javascript variables / or of HTML tags, see my example:
<td width="10"></td>
<td ><div id="combo_rub" style="CURSOR:pointer"></div><input type="hidden" id="rech_cod_cat" name="rech_cod_cat" value="1"/></td>
<td ><div id="combo_typ" style="CURSOR:pointer"></div></td>
<td ><div id="combo_sou_typ" style="CURSOR:pointer"></div></td>
<script type="text/javascript">
d_rech_cod_rub = "101";
d_rech_cod_typ = "1";
d_rech_cod_sou_typ = "1020121";
//ComboBox sous_type
var z_sou_typ=new dhtmlXCombo("combo_sou_typ","rech_cod_sou_typ",160);
So what i want in my code PHP is to retrieve the value of(d_rech_cod_rub, d_rech_cod_typ, d_rech_cod_sou_typ) from Javascript part, not from HTML as you can see…
the second scenario is:
<td><a href="AnnoncesImmobilier.asp?rech_cod_rub=101&rech_cod_typ=1">
<font color="#2154eb">Location (6920)</font></a> </td></tr></table></td></tr>
<tr><td><table width="100%" cellpadding="0" cellspacing="0"><tr>
<td><a href="AnnoncesImmobilier.asp?rech_cod_rub=101&rech_cod_typ=5"></td>
Same here i need to retrieve the ‘101’ value…
Finally, The full story: I’m using very frequently the Curl extension of PHP then I come across with a content like the above examples… the problem is when i use a HTML-Parser like (http://simplehtmldom.sourceforge.net/) i can not done my work with this, because it work only with a valid HTML..:(
my question: there is any solution to retrieve the values in a stable manner ?
what are you doing if you come across a case like me ?
Thanks guys.
EDIT : So according to most answers, using RegX do the trick…
The following regexes do the trick
Not sure about PHP but you might be able to evaluate it using the following code: