hi everyone

can anyone help me with the php pattern that search the following string and get relevent pattern.

"2004_8.rtf" (November) S v Mimi(000/00) [2004] NAME 8;
"2005_9.rtf" (November) S v Mimi(000/01) [2005] NAME 9;

i want the regular expression patterns that match this : [2005] NAME 9 ; or [2004] NAME 8; on the above strings.

(\[[0-9]{4}\] name [0-9];)$

Thanks it work but it match everything on the text file.and i have a different names i want to match a specific name line with the data posted from the form.i have different year ,name and number

the data posted by the user look like the one

$jaar = $_POST[year];
$name = $_POST[name];
number = $_POST[number];
look at my code maybe you will have a clear picture of what i am trying to do.

$name= $_POST;
echo $court."<br />";
echo $mnc."<br />";
$toSearch = "[".$jaar."]"." "$name." ".$number;
echo $toSearch."<br />";

$file =$q."Registry.txt";

$lines = file($file);


if ($lines)


foreach($lines as $lineNumber)


$foundAMatch = preg_match("/$toSearch/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);

if ($foundAMatch > 0)

echo $foundAMatch."<br />";

$found = $matches[0][0];

echo $lineNumber."<br />";






$line="no file/folder found";

echo $line;


Since the dat ais fixed, use:

$preg = "(\[$year\] $name $number;)\$";
$foundAMatch = preg_match("/$preg/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
This article has been dead for over six months. Start a new discussion instead.