Reply to Re: year in a (****) format

Your name:

Reply:


Posted by iktorn on 03/27/07 19:55

Krustov napisał(a):
> (1950)
> (1975)
> (2000)
> (2001)
>
> etc etc
>
> This sort of year will be somewhere in a one line string .
>
> (****)
>
> How do i search for a year like this thats between 2 curved brackets .
>
>
> While i could use strpos to find the first curved bracket then then
> check if theres a ) five letters along - some sort of wildcard method
> would obviously be much better .
>
> I also want to grab the date from the string to use elsewhere

You can try this:

<?php
$text ="sajdkahs (2005) asgjgdjasdkh (20056) hdsgfjsgfsd
ajgsda (1234 jksdhkjfhskjdh ) sgfdggsd (1256)";
if(preg_match_all("/\([0-9]{4}\)/",$text,$matches)) {
print_r($matches[0]);
}
?>

--
Wiktor Walc
http://phpfreelancer.net

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация