note 58481 added to function.preg-match
| From: | rebootconcepts dot com at osu1 dot php dot net | Date: | Sat, 05 Nov 2005 15:33:46 +0000 |
| Subject: | note 58481 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98132@lists.php.net to get a copy of this message | ||
Guarantee (one) trailing slash in $dir:
<?php
$dir = preg_match( '|(.*)/*$|U', $dir, $matches );
$dir = $matches[1] . '/';
?>
For whatever reason,
<?php $dir = preg_replace( '|^([^/]*)/*$|', '$1/', $dir ); ?>
and
<?php $dir = preg_replace( '|/*$|U', '/', $dir ); ?>
don't work (perfectly). The match, concat combo is the only thing I could get to work if there
was a '/' within $dir (like $dir = "foo/bar";
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58481
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58481&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58481&report=yes
Search -- http://master.php.net/manage/user-notes.php