Re: [PHP] ereg help!

2008-01-09 Thread Richard Heyes

$out = basename($file, .html) . .com;

fairly limited i think, but simple.


Nothing wrong with being simple, and therefore both fast and easy to 
understand by a wider audience. The only downer I can immediately think 
of though is that whitespace isn't accommodated, but who really ends a 
file name with white space?


--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ereg help!

2008-01-09 Thread Anup Shukla

steve wrote:

On Tuesday 08 January 2008 20:30:29 Chris wrote:

I usually use preg_* functions so here's my go:



echo preg_replace('/\.php$/', '.com', $file);


The '$' at the end makes sure it's a .php file and won't cause problems 
with files like xyz.php.txt .



(otherwise I'd just use a straight str_replace).


Thanks

Guess i was just trying to over think it. Have not done much with files.


Steve



$out = basename($file, .html) . .com;

fairly limited i think, but simple.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ereg help!

2008-01-08 Thread steve
I have a dir of html files that link to websites, i would like to read the dir 
and print a list of those files as a link. Which the script i have does. I 
would like to take this one step further and replace the .html extension 
with .com so it winds up being:
website.com instead of website.html

I am apparently having problems getting my head around eregi enough to 
acomplish this.

any help is greatly appreciated.

?
$source_dir = ./mydir;

$dir=opendir($source_dir);
$files=array();
while (($file=readdir($dir)) !== false)
{


if ($file != .  $file != ..  strpos(strtolower($file),.php) === 
false)
{
array_push($files, $file);
}
}
closedir($dir);
sort($files);
foreach ($files as $file)
{

echo A href='$file'$filebr;


}
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ereg help!

2008-01-08 Thread Chris

steve wrote:
I have a dir of html files that link to websites, i would like to read the dir 
and print a list of those files as a link. Which the script i have does. I 
would like to take this one step further and replace the .html extension 
with .com so it winds up being:

website.com instead of website.html

I am apparently having problems getting my head around eregi enough to 
acomplish this.


any help is greatly appreciated.

?
$source_dir = ./mydir;

$dir=opendir($source_dir);
$files=array();
while (($file=readdir($dir)) !== false)
{


if ($file != .  $file != ..  strpos(strtolower($file),.php) === 
false)

{
array_push($files, $file);
}
}
closedir($dir);
sort($files);
foreach ($files as $file)
{

echo A href='$file'$filebr;


}
?



I usually use preg_* functions so here's my go:

echo preg_replace('/\.php$/', '.com', $file);

The '$' at the end makes sure it's a .php file and won't cause problems 
with files like xyz.php.txt .


(otherwise I'd just use a straight str_replace).

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ereg help!

2008-01-08 Thread steve
On Tuesday 08 January 2008 20:30:29 Chris wrote:
I usually use preg_* functions so here's my go:

echo preg_replace('/\.php$/', '.com', $file);

The '$' at the end makes sure it's a .php file and won't cause problems 
with files like xyz.php.txt .

(otherwise I'd just use a straight str_replace).

Thanks

Guess i was just trying to over think it. Have not done much with files.


Steve

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ereg help!

2008-01-08 Thread Casey

On Jan 8, 2008, at 5:45 PM, steve [EMAIL PROTECTED] wrote:

I have a dir of html files that link to websites, i would like to  
read the dir
and print a list of those files as a link. Which the script i have  
does. I
would like to take this one step further and replace the .html  
extension

with .com so it winds up being:
website.com instead of website.html

I am apparently having problems getting my head around eregi enough to
acomplish this.

any help is greatly appreciated.

?
$source_dir = ./mydir;

$dir=opendir($source_dir);
$files=array();
while (($file=readdir($dir)) !== false)
{


if ($file != .  $file != ..  strpos(strtolower 
($file),.php) ===

false)
   {
   array_push($files, $file);
   }
}
closedir($dir);
sort($files);
foreach ($files as $file)
{

echo A href='$file'$filebr;


}
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



I think glob('*.html'); would be easier. 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Ereg help

2002-10-25 Thread William Glenn
Hey all,
I've been fighting this all night, I need a bit of help. I have a string like.

#21-935 Item Description: $35.95

Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits, and the price 
could be a combination of 1,2,3 . 2 digits. I want to chop that string into Part # / 
Description / Price. 

I'd appreciate any help, I know this is probably real simple :) Thanks in advance.

Thanks,
William Glenn
Import Parts Plus
http://www.importpartsplus.com


Re: [PHP] Ereg help

2002-10-25 Thread Rick Emery
?php
$s = #12-3456 The Item description $35.43;

$qq = ereg(#([0-9]*-[0-9]*) ([a-zA-Z0-9 ]*) \\$([0-9]{1,3}\.[0-9]{2}), $s,$a);

$val = $a[1]./.$a[2]./.$a[3];
print $val;

?

- Original Message -
From: William Glenn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, October 25, 2002 10:34 AM
Subject: [PHP] Ereg help


Hey all,
I've been fighting this all night, I need a bit of help. I have a string like.

#21-935 Item Description: $35.95

Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits, and the price
could be a combination of 1,2,3 . 2 digits. I want to chop that string into Part # /
Description / Price.

I'd appreciate any help, I know this is probably real simple :) Thanks in advance.

Thanks,
William Glenn
Import Parts Plus
http://www.importpartsplus.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Ereg Help

2002-10-25 Thread David Pratt
Hi William, try this:

^(#[0-9]{2}-[0-9]{2,4} Item Description: [\$][0-9]{1,3}[\.][0-9]{2})$

I've just been putting a number of expressions together for validation
myself.

Regards,
Dave Pratt



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ereg help

2001-12-03 Thread Valentin V. Petruchek


- Original Message -
From: Valentin V. Petruchek [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 03, 2001 6:35 PM
Subject: [PHP] ereg help


 I'm not new for php, but have no experience working with ereg functions.
My
 problem is the following:

 i have string.. for example
 $s=id {name,title,nick} [http://www.php.net];;
 i want to break it in several parts:
 $p[0]=id;
 $p[1][0] =name;
 $p[1][1] =title;
 $p[1][2] =nick;
 $p[2]=http://www.php.net;;

 The part in [] is not neccessary, count of {} elements is not less than 1
 I can do it with string fucntions, but it seemes to me it's better to use
 regular functions.

 Could anybody help me to solve this problem and advise resource for
studying
 regular expresions?

 Zliy Pes, http://zliypes.com.ua






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ereg help

2001-12-03 Thread Jim

This is a good starter about PHP and regular expressions.

http://www.phpbuilder.com/columns/dario19990616.php3


- Original Message -
From: Valentin V. Petruchek [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 03, 2001 6:35 PM
Subject: [PHP] ereg help


  I'm not new for php, but have no experience working with ereg functions.
My
  problem is the following:

  i have string.. for example
  $s=id {name,title,nick} [http://www.php.net];;
  i want to break it in several parts:
  $p[0]=id;
  $p[1][0] =name;
  $p[1][1] =title;
  $p[1][2] =nick;
  $p[2]=http://www.php.net;;

  The part in [] is not neccessary, count of {} elements is not less than 1
  I can do it with string fucntions, but it seemes to me it's better to use
  regular functions.

  Could anybody help me to solve this problem and advise resource for
studying
  regular expresions?

  Zliy Pes, http://zliypes.com.ua






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ereg help

2001-12-03 Thread J Smith


Something like this will work:

eregi(^id \{([a-z]*),([a-z]+),([a-z]+)\} \[(.+)\]$, $str, $regs);

$regs will be an array containing:

[0] = id {name,title,nick} [http://www.php.net];
[1] = name
[2] = title
[3] = nick
[4] = http://www.php.net;

If course this isn't very foolproof or generic. For instance, this regex 
assumes that you have exactly three comma-delimited substrings between 
those curly braces and anything goes in the brackets. (It could be a URL, 
but it could also be anything else.)

This is assuming there are three items between those curly braces, however. 

To handle multiple configurations within the curly braces, you'd probably, 
as the boundaries would cause items in the array to be overwritten during 
matching. Something like this may work half-decent...

if (eregi((id) \{(.*)\} \[(.*)\]$, $str, $regs))
{
$p[0] = $regs[1];
$p[1] = explode(,, $regs[2]);
$p[2] = $regs[3];
}

$p should now look like the following:

[0] = id
[1][0] = name
[1][1] = title
[1][2] = nick )
[2] = http://www.php.net;

That should do it. Of course, the regex again isn't foolproof, as you could 
have crazy stuff for a URL, and it doesn't bother to check if there's 
anything after a comma in the curly braces, but will handle any number of 
items between the braces, and it's enough to get you started.

J



Valentin V. Petruchek wrote:

 
 - Original Message -
 From: Valentin V. Petruchek [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, December 03, 2001 6:35 PM
 Subject: [PHP] ereg help
 
 
 I'm not new for php, but have no experience working with ereg functions.
 My
 problem is the following:

 i have string.. for example
 $s=id {name,title,nick} [http://www.php.net];;
 i want to break it in several parts:
 $p[0]=id;
 $p[1][0] =name;
 $p[1][1] =title;
 $p[1][2] =nick;
 $p[2]=http://www.php.net;;

 The part in [] is not neccessary, count of {} elements is not less than 1
 I can do it with string fucntions, but it seemes to me it's better to use
 regular functions.

 Could anybody help me to solve this problem and advise resource for
 studying
 regular expresions?

 Zliy Pes, http://zliypes.com.ua




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ereg() help, plz

2001-07-15 Thread Thomas R. Powell

Try this,

while ($file_name = readdir($dir2)) {

if ($file_name!=.  $file_name!=..  $file_name!=head.jpg  
!ereg(^tn_,$file_name)) {
$files[]=$file_name; 
}
}
$numfiles = count($files);
for ($i=$g; $i$numfiles; $i++){ 
echo $files[$i]; 
}

Tom

At 09:45 PM 7/14/01 -0400, you wrote:
hi,

I wanna print out all files in a directory. But i wanna exclude ., ..,
head.jpg, and all files that start with tn_

Here is my script, but it didn't work. Please help me to solve this problem.
Thank You.

-my script-
while ($file_name = readdir($dir2))

if (($file_name!=.  $file_name!=..  $file_name!=head.jpg 
$file_name!=ereg(^tn_,$file_name) ))

$files[]=$file_name;
}

$numfiles = count($files);

for ($i=$g; $i$numfiles; $i++){
echo $files[$i];
}

-





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] ereg() help, plz

2001-07-14 Thread McShen

hi,

I wanna print out all files in a directory. But i wanna exclude ., ..,
head.jpg, and all files that start with tn_

Here is my script, but it didn't work. Please help me to solve this problem.
Thank You.

-my script-
while ($file_name = readdir($dir2))

if (($file_name!=.  $file_name!=..  $file_name!=head.jpg 
$file_name!=ereg(^tn_,$file_name) ))

$files[]=$file_name;
}

$numfiles = count($files);

for ($i=$g; $i$numfiles; $i++){
echo $files[$i];
}

-





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]