poe Posted October 19, 2007 Share Posted October 19, 2007 i have a string <table><tr><td>8</td><td>date</td><td>10/15</td><td>W/L</td><td>2/11</td></tr></table> how do i replace all instances of the '/' (slash) with a ':' (colon) except for when it is not in a tag like </td> or </table> etc... i have, but does not work: $strHtml = eregi_replace("(-|/)",":",$strHtml); *** i also want to replace the dash with a colon, but that is not giving me a problem Link to comment https://forums.phpfreaks.com/topic/73961-solved-replace-all-except-in-a-tag/ Share on other sites More sharing options...
effigy Posted October 19, 2007 Share Posted October 19, 2007 If it's always for the >digits/digits< format: <pre> <?php $str = '<table><tr><td>8</td><td>date</td><td>10/15</td><td>W/L</td><td>2/11</td></tr></table>'; echo htmlspecialchars(preg_replace('#(?<=>)(\d+)/(?=\d+<)#', '\1:', $str)); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/73961-solved-replace-all-except-in-a-tag/#findComment-373262 Share on other sites More sharing options...
poe Posted October 19, 2007 Author Share Posted October 19, 2007 it could be for >numbers/numbers< OR >letters/letters< OR >letters or numbers / letters or numbers< Link to comment https://forums.phpfreaks.com/topic/73961-solved-replace-all-except-in-a-tag/#findComment-373306 Share on other sites More sharing options...
effigy Posted October 19, 2007 Share Posted October 19, 2007 If by "letters" you mean ASCII, replace \d with [a-zA-Z0-9]. Link to comment https://forums.phpfreaks.com/topic/73961-solved-replace-all-except-in-a-tag/#findComment-373308 Share on other sites More sharing options...
poe Posted October 19, 2007 Author Share Posted October 19, 2007 awsome, thankyou! Link to comment https://forums.phpfreaks.com/topic/73961-solved-replace-all-except-in-a-tag/#findComment-373313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.