Saturday, August 17, 2013

Remove string using preg_replace. Is there any other alternative?

Remove string using preg_replace. Is there any other alternative?

I need to remove some parts of string at regular intervals based on simple
special characters like _ and |. Here is my code:
<?php
$text =
"a*a1.zip,a2.zip|b*b1.zip|c*c1.zip|d*d1.zip|e*e1.zip|f*f1.zip|g*g1.zip|h*h1.zip";
$expl = explode("|", $text);
print_r($expl);
?>
I need to remove all the alphabets and *'s, |'s such that my output should
look like:
a1.zip,a2.zip,b1.zip,c1.zip,d1.zip,e1.zip,f1.zip,g1.zip,h1.zip
I am trying to use preg_replace but its very hard to understand :(. Is
there any other alternative? Thanks in advance...

No comments:

Post a Comment