Re: Regular Expression Help
| From: | Charles Killian | Date: | Fri, 18 Aug 2000 20:23:21 +0000 |
| Subject: | Re: Regular Expression Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12530@lists.php.net to get a copy of this message | ||
This should work:
$regex = "\\.php3\$;
print $regex;
if(eregi($regex, $entry_name))
It's only a quick guess.
ck
----- Original Message -----
Sent: Friday, August 18, 2000 12:51 PM
Subject: [PHP] Regular Expression Help
> Hi ya,
>
> I'm having some trouble with regular expressions using the
> eregi() function. I'm a newbie, not to php, but just to regular
> expressions in general.
>
> What I'm trying to do is print out an option list of only 777 'moded
> files
> with .php3 extensions. The "33279" is just what 0777 in octal(?) prints
>
> out as in base 10. I didn't have the energy to convert it, and it works
>
> fine.
>
> <?php
> if(!isset($requested_dir)) { $requested_dir = "."; }
> $current_directory = opendir($requested_dir);
> while ($entry_name = readdir($current_directory))
> {
> if(is_file($entry_name))
> {
> $chmod_number = fileperms($entry_name);
> if($chmod_number == "33279")
> {
> if(eregi("^[[:>:]]/.php3$", $entry_name))
> {
> print("<option>$entry_name</option>\n");
> }
> }
> }
> }
> print("</select>\n");
> ?>
>
> As you can see, my regular expression is screwed up. I've looked in
> 2 books ( Core PHP and Programming Browser Based Applications
> in PHP3 ) and they both really glossed over the subject of regular
> expressions.
>
> Basically, I just need the regular expression code that would take a
> string ( test.php3 ) for example, and just check for the .php3
> extension.
>
> Thanks in advance
> -Alex
>
> --
> Alex Augot ex.3065
> Software Process Engineering Group
> Teradyne, Inc
> Phone: 617-422-3065
> Cell: 617-435-7035
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>