poe Posted March 19, 2008 Share Posted March 19, 2008 i grabbed a table and loop through each <tr> into an array i am now cleaning the tags like so: foreach($strHtml as $k => $v) { $myHtml = $v; $myHtml = preg_replace('/\s+/s',"",$myHtml); $myHtml = preg_replace('/^\s+/s',"",$myHtml); $myHtml = preg_replace('/\s+$/s',"",$myHtml); $myHtml = preg_replace('#(?<=>)([a-zA-Z0-9]+)/(?=[a-zA-Z0-9]+<)#', '\1:', $myHtml); $myHtml = eregi_replace("-",":",$myHtml); $myHtml = eregi_replace("<table[^>]*>","<table>",$myHtml); $myHtml = eregi_replace("<tr[^>]*>","<tr>",$myHtml); $myHtml = eregi_replace("<td[^>]*>","<td>",$myHtml); $myHtml = eregi_replace("<img[^>]*>","",$myHtml); $myHtml = eregi_replace("</?font[^>]*>","",$myHtml); $myHtml = eregi_replace("</td><td>","~",$myHtml); $myHtml = eregi_replace("</?tr[^>]*>","",$myHtml); $strHtml[$k] = $myHtml; } which works ok except i have one tag (which changes on each forloop) (ie. new date): <a href="/baseball/mlb/boxscores/2008/03/02/21592_boxscore.html">Box Score</a> which i want to keep the "/2008/03/02/21592" part. and add an "-" to the front and back like: "-/2008/03/02/21592-" i have tried this, but i think it is completely wrong... because it gives me error and because i made up the '-$saved-' part $myHtml = eregi_replace("<ahref=\"\/baseball\/mlb\/boxscores(.*?)","-$saved-",$myHtml); thanks ck Quote Link to comment Share on other sites More sharing options...
effigy Posted March 19, 2008 Share Posted March 19, 2008 Try giving it a stopping point: \" Quote Link to comment Share on other sites More sharing options...
poe Posted March 19, 2008 Author Share Posted March 19, 2008 i dont know what you mean? Quote Link to comment Share on other sites More sharing options...
effigy Posted March 19, 2008 Share Posted March 19, 2008 (.*?) is lazy, so it's going to match as little as possible. Since it's at the end of the pattern, there's no reason for it to match anything at all. Try following it with \". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.