| | |
regular expression patterns
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 14
Reputation:
Solved Threads: 0
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.
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.
PHP Syntax (Toggle Plain Text)
(\[[0-9]{4}\] name [0-9];)$
Last edited by pritaeas; Aug 14th, 2008 at 7:20 am.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Aug 2008
Posts: 14
Reputation:
Solved Threads: 0
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.
$q=$_POST['path'];
$jaar=$_POST['years'];
$name= $_POST['Name'];
echo $court."<br />";
$number=$_POST['Number'];
echo $mnc."<br />";
$toSearch = "[".$jaar."]"." "$name." ".$number;
echo $toSearch."<br />";
$file =$q."Registry.txt";
$lines = file($file);
$count;
$lineNumbers;
if ($lines)
{
foreach($lines as $lineNumber)
{
$lineNumbers++;
$foundAMatch = preg_match("/$toSearch/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
if ($foundAMatch > 0)
{
echo $foundAMatch."<br />";
$found = $matches[0][0];
$count=$lineNumber;
echo $lineNumber."<br />";
write($lineNumbers,$lineNumber);
}
}
}
else
{
$line="no file/folder found";
echo $line;
}
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.
$q=$_POST['path'];
$jaar=$_POST['years'];
$name= $_POST['Name'];
echo $court."<br />";
$number=$_POST['Number'];
echo $mnc."<br />";
$toSearch = "[".$jaar."]"." "$name." ".$number;
echo $toSearch."<br />";
$file =$q."Registry.txt";
$lines = file($file);
$count;
$lineNumbers;
if ($lines)
{
foreach($lines as $lineNumber)
{
$lineNumbers++;
$foundAMatch = preg_match("/$toSearch/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
if ($foundAMatch > 0)
{
echo $foundAMatch."<br />";
$found = $matches[0][0];
$count=$lineNumber;
echo $lineNumber."<br />";
write($lineNumbers,$lineNumber);
}
}
}
else
{
$line="no file/folder found";
echo $line;
}
Since the dat ais fixed, use:
PHP Syntax (Toggle Plain Text)
$preg = "(\[$year\] $name $number;)\$"; $foundAMatch = preg_match("/$preg/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
![]() |
Similar Threads
- multiple variables in a mod_rewrite URL string (Linux Servers and Apache)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Open In New Window Php (PHP)
- Regular Expression to match patterns (C#)
- Converting special regular expression quantifiers to NFAs efficiently (Computer Science)
- Regular expression doesn't make sense (Perl)
- Searching problem (C++)
Other Threads in the PHP Forum
- Previous Thread: run php file as services in linux
- Next Thread: Sending form data in an email
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





