Forum Moderators: coopster
<?php
// strip year
$patterns = array ("/\b[0-9]{4}\b/");
$replace = array("");
$description = preg_replace($patterns, $replace, $description);
?>
..but for reason it doesn't work. When I remove the count {4} the regex engine strips all numbers just fine, but my intention is to strip a literal of four consecutive numbers as in a year. (Nvm that this regex will also match 9823 or 0325 - for my site the simple solution will work).
Can anyone tell me what I am doing wrong? I have also tried:
array ("/\b\d{4}\b/");
but that doesn't work either.
Any helps is MUCH appreciated.
Sincerely,
Joe Belmaati
Copenhagen Denmark
<?php
// strip numbers (vintage)
$pattern = '/\d{4,4}/';
$description = preg_replace($pattern, '', $description);
?> works perfectly, but
<?php
// strip numbers (vintage)
$pattern = '/\d{4}/';
$description = preg_replace($pattern, '', $description);
?> gives me a parse error. I should state that my code is inside a phpbb bulletin board and that it is pulling topics out of a mysql db. Anyhow, I have solved my problem with coopster's help - just thought that the above mentioned is slightly weird.