June 23, 201114 yr comment_9334 How can I convert this to preg_replace?$TEMPLATE_PATH = ereg_replace("(/)+" ,"/",$TEMPLATE_PATH); Thanks! Report
June 23, 201114 yr comment_9335 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; ?> Report
June 24, 201114 yr Author comment_9340 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 Report
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.