point3d Posted June 23, 2011 Report Share Posted June 23, 2011 How can I convert this to preg_replace?$TEMPLATE_PATH = ereg_replace("(/)+" ,"/",$TEMPLATE_PATH); Thanks! Quote Link to comment Share on other sites More sharing options...
Coral Posted June 23, 2011 Report Share Posted June 23, 2011 The regex uses / as the delimiter when searching for / you escape it like so \/ see example test code <?php $TEMPLATE_PATH ="c://test//example/////test.php"; print $TEMPLATE_PATH; $TEMPLATE_PATH = ereg_replace("(/)+" ,"/",$TEMPLATE_PATH); //----Deprecated $TEMPLATE_PATH = preg_replace('/(\/)+/', '/', $TEMPLATE_PATH); print $TEMPLATE_PATH; ?> Quote Link to comment Share on other sites More sharing options...
point3d Posted June 24, 2011 Author Report Share Posted June 24, 2011 Thank you very much! Quote Link to comment Share on other sites More sharing options...
point3d Posted June 24, 2011 Author Report Share Posted June 24, 2011 Almost finished the fix for php 5.3 But stuck with this "Easy-to-Read" code $REP_UNDSCR="&| "; $REP_SPACE="\?|%|'|\"|'|%|/|\||"|\*|#|\^|{|}|;|!|:|~|`|<|>|<|>|,|\\|\(|\)"; $ADDITIONAL_VAL = ereg_replace($REP_UNDSCR,'_',$ADDITIONAL_VAL); $ADDITIONAL_VAL = ereg_replace($REP_SPACE,'',$ADDITIONAL_VAL); Someone can help to convert this to preg_replace 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.