point3d Posted June 23, 2011 Report Posted June 23, 2011 How can I convert this to preg_replace?$TEMPLATE_PATH = ereg_replace("(/)+" ,"/",$TEMPLATE_PATH); Thanks! Quote
Coral Posted June 23, 2011 Report 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
point3d Posted June 24, 2011 Author Report 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
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.