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]
|