Reply to Re: preg help

Your name:

Reply:


Posted by Mladen Gogala on 11/07/58 11:29

On Thu, 13 Oct 2005 05:34:22 -0700, system7designs@gmail.com wrote:

> I don't know preg's that well, can anyone tell me how to write a
> regular expression that will select everything BUT files/folders that
> begin with ._ or __?(that's period-underscore and underscore
> underscore)

This is probably what you want:

<?php
$patt='/^[^_.][^-]?/';
$str=array("._test","__test","_test","test","_",".","A");
foreach ($str as $i) {
if (preg_match($patt,$i)) {
print "Term $i matches pattern $patt\n";
} else print "Term $i doesn\'t match pattern $patt\n";
}
?>

When executed, it produces the following:

Term ._test doesn\'t match pattern /^[^_.][^-]?/
Term __test doesn\'t match pattern /^[^_.][^-]?/
Term _test doesn\'t match pattern /^[^_.][^-]?/
Term test matches pattern /^[^_.][^-]?/
Term _ doesn\'t match pattern /^[^_.][^-]?/
Term . doesn\'t match pattern /^[^_.][^-]?/
Term A matches pattern /^[^_.][^-]?/


--
http://www.mgogala.com

[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

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