Page 1 of 1
preg_replace
Posted: Wed Dec 15, 2004 8:31 pm
by emanresusdrawkcab
what would be the pattern thingo for a date like
?
i've got a load of them in an array, and I want to get rid of them.
i tried
Code: Select all
$pattern = "(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z";
preg_replace($modPat,"", $arrayWithStuff);
but it buggered up....
thanks in advance,
matt.
Posted: Wed Dec 15, 2004 8:36 pm
by rehfeld
the pattern looks ok, i think you just forgot the delimiters
Code: Select all
<?php
$pattern = "/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z/";
preg_replace($pattern,"", $arrayWithStuff);
?>
Posted: Wed Dec 15, 2004 8:39 pm
by emanresusdrawkcab
nope, still not working :'(
oh yeah, and I made sure my variables had the same name

Posted: Wed Dec 15, 2004 8:43 pm
by rehfeld
is there an error?
instead of
([\d]+)
try
([0-9]+)
Posted: Wed Dec 15, 2004 8:47 pm
by emanresusdrawkcab
nope, it either returns what i originally had, or it's returning "Array" so i probably need to have a "print_r" somewhere
Code: Select all
$pattern = "/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z/";
$myArray = (ereg_replace($pattern, "", $myArray));
print_r($myArray);
oh yeah, am i supposed to be using Preg or Ereg ?
Posted: Wed Dec 15, 2004 8:52 pm
by emanresusdrawkcab
i've done it! thanks for your help
Code: Select all
$pattern = "/(ї0-9]+)-(ї0-9]+)-(ї0-9]+)T(ї0-9]+):(ї0-9]+):(ї0-9]+)Z/";
$myArray = preg_replace($pattern, "", $myArray);
print_r($myArray);