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



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



Re: [PHP] ereg() problem

2007-01-31 Thread Jim Lucas

jekillen wrote:

Hello php list;

I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m);

do we need to break out of the text to include the $to variable??


testing $route I get:

do you mean $get_route?


$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)

Is this an example of th input?

What does an actual line of $get_route look like?

do a var_dump($m); and show output


jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK



or better yet, try this

I am assuming on the actual structure of $get_route but the following 
return to me $match[1] = '../jk'


$to = 'something';
$get_route = route name='something' x='../jk/in' rec='998asdf' /;
preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, 
$get_route, $matches);

var_dump($matches);



--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different 
strings. But there are times for you and me when all such things agree.


- Rush

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



Re: [PHP] ereg() problem

2007-01-31 Thread jekillen


On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote:


jekillen wrote:

Hello php list;
I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, 
$m);

do we need to break out of the text to include the $to variable??

The $to variable is what I use to id the tag to get the path from, it is
critical. It is like answering the question 'What is Joe's address?'
Joe in this example is the $to variable.




testing $route I get:

do you mean $get_route?

No, I mean $route after I have assigned $m[1] to it;



$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)

Is this an example of th input?

This is what the regular expression (.*) is matching
in the tag. It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.


What does an actual line of $get_route look like?

$get_route is what was read from the XML file.
It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.



do a var_dump($m); and show output

The problem is that the regex is missing the closing single quote and
matching to the end of the tag instead of just matching what is between
the  parenthesis.



jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK


or better yet, try this

I am assuming on the actual structure of $get_route but the following 
return to me $match[1] = '../jk'


$to = 'something';
$get_route = route name='something' x='../jk/in' rec='998asdf' /;
preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, 
$get_route, $matches);

var_dump($matches);
O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is 
supposed to

contain the matches made by each set of parenthesis.
Does anyone know or understand the concept of greed in regular
expressions, and how to turn it off in php? That is all I am asking for.
JK

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



Re: [PHP] ereg() problem

2007-01-31 Thread Richard Lynch
On Tue, January 30, 2007 8:36 pm, jekillen wrote:
 I am having trouble with ereg().
 The following is the problem code
 $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route,
 $m);
 testing $route I get:
 $route = $m[1];
 print $route.'br';
 jk/in' rec='a_378e6dc4.xml' / (out put of print)
 jk is all I am looking for but
 is it greed that is missing the
 forward slash and the single quote?

No, it's that you put the parens () around only the .* and not around
what you wanted:
ereg(route name='$to' x='\\.\\.(.*/in') rec='.*' /, ...

 It seems like every time I do this I have to monkey around
 with it until I get what I want.

Join the club. :-)

You may want to consider a couple actions:
  Switch to PCRE http://php.net/pcre

It's better documented, less confusing, faster, and just better all
around.

Download and play around with The Regex Coach which provides a
visual feedback on what happens when you change the #$^% inside your
pattern.

 I have even changed the
 formatting of files just so a regular expression would
 work without this sort of trial and error.
 Is there a way I can turn off greed in php's regex?

I haven't used ereg in so long, I can't answer this for ereg.
In PCRE, you use tack on 'U' after your end patter delimiter.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] ereg() problem

2007-01-31 Thread Jim Lucas

jekillen wrote:


On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote:


jekillen wrote:

Hello php list;
I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, 
$m);

do we need to break out of the text to include the $to variable??

The $to variable is what I use to id the tag to get the path from, it is
critical. It is like answering the question 'What is Joe's address?'
Joe in this example is the $to variable.




testing $route I get:

do you mean $get_route?

No, I mean $route after I have assigned $m[1] to it;



$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)

Is this an example of th input?

This is what the regular expression (.*) is matching
in the tag. It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.


What does an actual line of $get_route look like?

$get_route is what was read from the XML file.
It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.



do a var_dump($m); and show output

The problem is that the regex is missing the closing single quote and
matching to the end of the tag instead of just matching what is between
the  parenthesis.



jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK


or better yet, try this

I am assuming on the actual structure of $get_route but the following 
return to me $match[1] = '../jk'


$to = 'something';
$get_route = route name='something' x='../jk/in' rec='998asdf' /;
preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, 
$get_route, $matches);

var_dump($matches);
O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is 
supposed to

contain the matches made by each set of parenthesis.
Does anyone know or understand the concept of greed in regular
expressions, and how to turn it off in php? That is all I am asking for.
JK



Check out this working example of what I think you are asking for.

http://www.cmsws.com/examples/php/ereg.phps

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



Re: [PHP] ereg() problem

2007-01-31 Thread Jim Lucas

jekillen wrote:


On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote:


jekillen wrote:

Hello php list;
I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, 
$m);

do we need to break out of the text to include the $to variable??

The $to variable is what I use to id the tag to get the path from, it is
critical. It is like answering the question 'What is Joe's address?'
Joe in this example is the $to variable.




testing $route I get:

do you mean $get_route?

No, I mean $route after I have assigned $m[1] to it;



$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)

Is this an example of th input?

This is what the regular expression (.*) is matching
in the tag. It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.


What does an actual line of $get_route look like?

$get_route is what was read from the XML file.
It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.



do a var_dump($m); and show output

The problem is that the regex is missing the closing single quote and
matching to the end of the tag instead of just matching what is between
the  parenthesis.



jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK


or better yet, try this

I am assuming on the actual structure of $get_route but the following 
return to me $match[1] = '../jk'


$to = 'something';
$get_route = route name='something' x='../jk/in' rec='998asdf' /;
preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, 
$get_route, $matches);

var_dump($matches);
O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is 
supposed to

contain the matches made by each set of parenthesis.
Does anyone know or understand the concept of greed in regular
expressions, and how to turn it off in php? That is all I am asking for.
JK



Sent you the source link.  Try it without the 's' at the end.

http://www.cmsws.com/examples/php/ereg.php

http://www.cmsws.com/examples/php/ereg.php

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



Re: [PHP] ereg() problem: solution

2007-01-31 Thread jekillen

Hi
In reference to my query about 'greed' in regex in php and the following
code
$x = ereg(route name='$to' x='\.\./(.*)/in' rec='.*' /, 
$get_route, $m);

I solved the immediate problem with the following:
route name='$to' x='\.\./([a-z]{2}|a?u_[0-9a-z]{8})/in' rec='.*' /
as you can see, the regex is quite a bit more complicated and I
do not know if it will match all the possibilities that it will have to.
It looks like it should. one possibility that it is matching is just two
letters, in this case jk. The other possibility is u_ or  au_ followed
by 8 randomly selected letters and/or numbers.
In short I was trying to be as simple and comprehensive as
possible with (.*) as the regular expression. But the idea of greed
came to mind when the match was containing far more than antic-
ipated. Greed is when the regular expression tries to match as much
as possible, in this case (.*) appears to be matching every instance of
anything and everything else in the way, so it ends up including the
entire balance of the line. A least that is my explanation. So I did
something more complicated to get what I wanted. Simplicity is not
always so simple.
Thanks for all responses.
JK

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



Re: [PHP] ereg() problem

2007-01-31 Thread jekillen


On Jan 31, 2007, at 4:38 PM, Richard Lynch wrote:


On Tue, January 30, 2007 8:36 pm, jekillen wrote:

I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route,
$m);
testing $route I get:
$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)
jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?


No, it's that you put the parens () around only the .* and not around
what you wanted:
ereg(route name='$to' x='\\.\\.(.*/in') rec='.*' /, ...


It seems like every time I do this I have to monkey around
with it until I get what I want.


Join the club. :-)

You may want to consider a couple actions:
  Switch to PCRE http://php.net/pcre

It's better documented, less confusing, faster, and just better all
around.

Download and play around with The Regex Coach which provides a
visual feedback on what happens when you change the #$^% inside your
pattern.


I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?


I haven't used ereg in so long, I can't answer this for ereg.
In PCRE, you use tack on 'U' after your end patter delimiter.


Thanks, I believe I do have pcre in my installation, and that
was my next target for investigation. As I turns out I got a
regex that works, albeit more complicated than (.*). See this
post subject + solution. by me.
thanks for the response.
JK

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



Re: [PHP] Ereg problem

2006-06-27 Thread Robert Cummings
On Tue, 2006-06-27 at 12:14, Beauford wrote:
 One more in my recent woes. The last elseif does not work in the code below
 - even if the string is correct it always says it's incorrect. Even if I
 remove everything else and just have the ereg satement is doesn't work
 either.
 
 The code below is in a function and $_POST['password1'] is passed to the
 function. 
 
   $field = password1;  //Use field name for password
 
   if(!$subpass){
  $form-setError($field,  Password not entered);
   }
   elseif(strlen($subpass)  6) {
   $form-setError($field,  Too Short);
   }
   elseif(strlen($subpass)  10) {
   $form-setError($field,  Too Long);
   }
   elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) {
   $form-setError($field,  Not alphanumeric); 
   }

You're double negating. You check the negative return of ereg() and ereg
checks for the pattern NOT existing.

?php

elseif( !ereg( '[A-Za-z0-9]', trim( $subpass ) ) )

// the ereg check is still wrong though and should be...

elseif( !ereg( '^[A-Za-z0-9]+$', trim( $subpass ) ) )

// though personally, I'd use the following...

elseif( !ereg( '^[[:alnum:]]+$', trim( $subpass ) ) )

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Ereg problem

2006-06-27 Thread John Nichel

Beauford wrote:

Please turn of your mail client's request for return receipts when 
sending to a mailing list.


--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



RE: [PHP] Ereg problem

2006-06-27 Thread Beauford


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: June 27, 2006 12:58 PM
To: Beauford
Cc: PHP-General
Subject: Re: [PHP] Ereg problem

On Tue, 2006-06-27 at 12:14, Beauford wrote:
 One more in my recent woes. The last elseif does not work in the code 
 below
 - even if the string is correct it always says it's incorrect. Even if 
 I remove everything else and just have the ereg satement is doesn't 
 work either.
 
 The code below is in a function and $_POST['password1'] is passed to 
 the function.
 
   $field = password1;  //Use field name for password
 
   if(!$subpass){
  $form-setError($field,  Password not entered);
   }
   elseif(strlen($subpass)  6) {
   $form-setError($field,  Too Short);
   }
   elseif(strlen($subpass)  10) {
   $form-setError($field,  Too Long);
   }
   elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) {
   $form-setError($field,  Not alphanumeric); 
   }

You're double negating. You check the negative return of ereg() and ereg
checks for the pattern NOT existing.

?php

elseif( !ereg( '[A-Za-z0-9]', trim( $subpass ) ) )

// the ereg check is still wrong though and should be...

elseif( !ereg( '^[A-Za-z0-9]+$', trim( $subpass ) ) )

// though personally, I'd use the following...

elseif( !ereg( '^[[:alnum:]]+$', trim( $subpass ) ) )

?

Ahhh, I was thinking of it the other way round.  Thanks.

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



Re: [PHP] ereg function

2004-12-31 Thread Rasmus Lerdorf
Numbers are pretty easy.  You could just do:

   $age = (int)$_POST['age'];
   if($age  9) do_something();
   else do_something_else();

Using ereg doesn't make much sense in this case.

-Rasmus

On Fri, 31 Dec 2004, Michael Lutaaya wrote:

 I want to validate someones age. How do I do this in
 the ereg function.

 I also have some visitors on my site who are in
 between the ages of 7-9 so don't forget to make them
 part of the ereg function.

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


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



Re: [PHP] ereg function

2004-12-31 Thread Rory Browne
The ereg function doesn't have the capability to test the age of the
person viewing your page. You have to depend on them to input their
age in some way.

Your answer depends on how your age is submitted. Assuming it is
submited as $_POST['age'], you could perhaps use ereg(0*[7-9]$,
$_POST['age']) - that might work but I haven't used ereg - ever, I
perfer to use the faster PCRE regex functions, such as
preg_match(/^0*[7-9]$/, $_POST['age']); which will match any amount
of zeros, followed by anything between 7 and 9, ie 8,
008, or 08

Having all that said, I wouldn't use reges for smething like this.

On Fri, 31 Dec 2004 15:46:46 -0500 (EST), Michael Lutaaya
[EMAIL PROTECTED] wrote:
 I want to validate someones age. How do I do this in
 the ereg function.
 
 I also have some visitors on my site who are in
 between the ages of 7-9 so don't forget to make them
 part of the ereg function.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



RE: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???

2004-04-14 Thread Jay Blanchard
[snip]
:#039;(
:#039;-(

this causes the entire message to disappear:

$text = ereg_replace(':#039;-?(','img
src='.$smiley_path.'/crying.gif 
alt=:#039;( width=25 height=15 align=absmiddle',$text);
[/snip]

Have you tried any of the other regular expression functions available?

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



[PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread -{ Rene Brehmer }-
Never mind y'all ... me stupid ...

obviously the ( has meaning, and needs to be escaped ... was starting to 
think it could only do 2 ereg's in 1 script *sigh*

Sorry for wasting time and bandwidth ... the function now looks like this 
and works :

function gfx_smiley($text) {
  $smiley_path = 'smiley';
  $text = eregi_replace(':-?D','img src='.$smiley_path.'/biggrin.gif 
alt=:D width=15 height=15 align=absmiddle',$text);
  $text = ereg_replace(':-?\?','img src='.$smiley_path.'/confused.gif 
alt=:? width=15 height=22 align=absmiddle',$text);
  $text = ereg_replace(':#039;-?\(','img 
src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 
align=absmiddle',$text);
  $text = ereg_replace(':-?\(','img src='.$smiley_path.'/frown.gif 
alt=:( width=15 height=15 align=absmiddle',$text);

  return $text;
}
At 15:43 14-04-2004, -{ Rene Brehmer }- wrote:
I'm trying to do graphical smileys for my guestbook, but I've run into a 
problem with the crying smilies:

I need to replace :'( and :'-( ... or as they look in the post after being 
entered through htmlentities with ent_quotes on:

:#039;(
:#039;-(
this causes the entire message to disappear:

$text = ereg_replace(':#039;-?(','img src='.$smiley_path.'/crying.gif 
alt=:#039;( width=25 height=15 align=absmiddle',$text);

only the format of the search part differs from my other smiley 
replacements, so obviously that's where the problem is ... afaik, neither 
, # or ; have any meaning in regex, so I don't get what causes it ... 
I've tried escaping all of those chars, and it still causes $text to come 
back empty...

any ideas will be highly appreciated...
--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Tom Rogers
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...

RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*

RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :


You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 

-- 
regards,
Tom

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



Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread -{ Rene Brehmer }-
At 15:02 14-04-2004, Tom Rogers wrote:
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...
RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*
RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :
You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 
Hmm ... that looks like it only does Perl-based regex ???  Thing is the 
programs I normally do regex in either use Posix based or Unix (Cshell) 
based (mostly used at the latter, cuz that's what Forte Agent uses for its 
filters) ... how big a difference is there from the posix based to the perl 
based anyway ??? ... the samples in the manual ain't the same for 
preg_replace() and ereg_replace(), so it's a bit hard to get a quick 
glimpse of how big the difference really is ... (or for the _match() ones 
for that matter)...

But thx ... looks useful :)

Rene

--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re[2]: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Tom Rogers
Hi,

Thursday, April 15, 2004, 8:56:05 AM, you wrote:
RB At 15:02 14-04-2004, Tom Rogers wrote:
Hi,

Thursday, April 15, 2004, 12:51:20 AM, you wrote:
RB Never mind y'all ... me stupid ...

RB obviously the ( has meaning, and needs to be escaped ... was starting to
RB think it could only do 2 ereg's in 1 script *sigh*

RB Sorry for wasting time and bandwidth ... the function now looks like this
RB and works :


You might find this very useful :)

http://weitz.de/regex-coach/

Helps my old brain 

RB Hmm ... that looks like it only does Perl-based regex ???  Thing is the
RB programs I normally do regex in either use Posix based or Unix (Cshell)
RB based (mostly used at the latter, cuz that's what Forte Agent uses for its
RB filters) ... how big a difference is there from the posix based to the perl
RB based anyway ??? ... the samples in the manual ain't the same for 
RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick
RB glimpse of how big the difference really is ... (or for the _match() ones
RB for that matter)...

RB But thx ... looks useful :)


RB Rene

RB -- 
RB Rene Brehmer
RB aka Metalbunny

RB ~ If you don't like what I have to say ... don't read it ~

RB http://metalbunny.net/
RB References, tools, and other useful stuff...
RB Check out the new Metalbunny forums @ http://forums.metalbunny.net/

Yes it is based on perl regular expressions which are pretty close to
posix, close enough for simple stuff anyway.
preg_replace is quite a bit faster than ereg_replace, I know preg_*
functions keep a cache of expressions which can speed up repetitive
uses. Not sure about ereg functions though.

-- 
regards,
Tom

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



Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}

2004-04-14 Thread Curt Zirzow
* Thus wrote Tom Rogers ([EMAIL PROTECTED]):
 Hi,
 
 Thursday, April 15, 2004, 8:56:05 AM, you wrote:
 RB At 15:02 14-04-2004, Tom Rogers wrote:
...

 RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick
 RB glimpse of how big the difference really is ... (or for the _match() ones
 RB for that matter)...
 
 RB But thx ... looks useful :)
 
 
 Yes it is based on perl regular expressions which are pretty close to
 posix, close enough for simple stuff anyway.
 preg_replace is quite a bit faster than ereg_replace, I know preg_*
 functions keep a cache of expressions which can speed up repetitive
 uses. Not sure about ereg functions though.

From all benchmarks I've seen pcre beats posix hands down, not to
mention that pcre is much more powerful.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] ereg problem

2004-03-12 Thread Newman Weekly.
Don't worry about this I worked out that the example was wrong (o;

- Original Message - 
From: Newman Weekly. [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, March 13, 2004 1:59 PM
Subject: [PHP] ereg problem


?php  

$formUserName=foobar;

   if (ereg(^[a-bA-B][a-bA-B0-9]{3,11}$,$formUserName)
   {
   // IS VALID.
$pageUserNameValid=YES;
   }
   else
   {
   // NOT VALID
$pageUserNameValid=NO;
   }
 // PAGE OUT PUT..
  echo $pageUserNameValid;

?

This simple script is ment to check to a user nae field but I have done something 
wrong.  

$pageUserNameValid This should be yes for foo bar.

// Phil

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



Re: [PHP] ereg + performance problem

2004-01-02 Thread Mirek Novak
Hi,
 I think that smarty [ http://smarty.php.net ] can do this for u. It 
has tag nesting and, of course, you can define your own tag as a plugin.

As for performance problem - this is known feature of regexp. Solution 
is not simple. You, IMHO, have to rethink your approach. For parsing 
larger or complex files is much better to use state machine (finite 
state automaton). Try to search google for more theory. For ex. 
http://en.wikipedia.org/wiki/Finite_state_automaton

Martin Helie wrote:
Hello,

I'm writing a routine that recursively reads an HTML document, looking for
special tags. It's a template system, but contrary to what I've seen out
there so far, no template engines allow for any kind of customization from
within the document; they only seem to be variable replacement systems.
What I have in mind is something along the lines of:

HTML
blah blah
{MAGICTAG param1=a param2=b}some more {ANOTHERTAG}text{/ANOTHERTAG} here
{/MAGICTAG}
blah
/HTML
The text between ANOTHERTAG would first be changed and then passed along
with the other text to MAGICTAG. ie, the data is treated from the inside
out, and nesting is obviously supported.
I've got everything working, but the problem is I'm using quite a few ereg
statements recursively, so performance is not so good.
Here's a simplified version of the core (it's part of a class, and I
modified the code for a standalone version here).
Thanks in advance for any ideas. Feel free to recycle this code.

function parse( $template ) {

//Look for (before*) {a tag} (after*) anything and store matches in
$regs
if( ereg( (.*)[{]([a-zA-Z0-9]+)[}](.*), $template, $regs ) ) {
$before = $regs[1];
$tag = $regs[2];
//Now look for (data*) {/closing tag} (after*) in the after
portion of first match
if( ereg( (.*)[{][/] . $tag. [}](.*), $regs[3], $regs ) ) {
$after = $regs[2];
$data = $regs[1];
$resolvedTag = initHandler( $tag, $data ); //handle this tag and
data
}
//support for standalone tags (no {/closing tag} )
else {
ereg( (.*), $regs[3], $regs );
$resolvedTag = getTagValue( $tag );
$after = $regs[1];
}
}
if( $resolvedTag ) {
$template =
$before
. $resolvedTag
. $after;
parse( $template );
}
else {
return $template;
}
}
--
Mirek Novak
jabberID: [EMAIL PROTECTED]
ICQ: 119499448
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] ereg + performance problem

2004-01-02 Thread Martin Helie
Hi Mirek,

thanks for pointing this out. This looks like a great site -- although, as
you say, will require some [longer term] study.

I'll have closer look at Smarty as well...


Mirek Novak [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,
   I think that smarty [ http://smarty.php.net ] can do this for u. It
 has tag nesting and, of course, you can define your own tag as a plugin.

 As for performance problem - this is known feature of regexp. Solution
 is not simple. You, IMHO, have to rethink your approach. For parsing
 larger or complex files is much better to use state machine (finite
 state automaton). Try to search google for more theory. For ex.
 http://en.wikipedia.org/wiki/Finite_state_automaton

 Martin Helie wrote:
  Hello,
 
  I'm writing a routine that recursively reads an HTML document, looking
for
  special tags. It's a template system, but contrary to what I've seen
out
  there so far, no template engines allow for any kind of customization
from
  within the document; they only seem to be variable replacement systems.
 
  What I have in mind is something along the lines of:
 
  HTML
  blah blah
  {MAGICTAG param1=a param2=b}some more {ANOTHERTAG}text{/ANOTHERTAG}
here
  {/MAGICTAG}
  blah
  /HTML
 
  The text between ANOTHERTAG would first be changed and then passed along
  with the other text to MAGICTAG. ie, the data is treated from the inside
  out, and nesting is obviously supported.
 
  I've got everything working, but the problem is I'm using quite a few
ereg
  statements recursively, so performance is not so good.
 
  Here's a simplified version of the core (it's part of a class, and I
  modified the code for a standalone version here).
 
  Thanks in advance for any ideas. Feel free to recycle this code.
 
  function parse( $template ) {
 
  //Look for (before*) {a tag} (after*) anything and store matches in
  $regs
  if( ereg( (.*)[{]([a-zA-Z0-9]+)[}](.*), $template, $regs ) ) {
  $before = $regs[1];
  $tag = $regs[2];
 
  //Now look for (data*) {/closing tag} (after*) in the after
  portion of first match
  if( ereg( (.*)[{][/] . $tag. [}](.*), $regs[3], $regs ) ) {
  $after = $regs[2];
  $data = $regs[1];
  $resolvedTag = initHandler( $tag, $data ); //handle this tag
and
  data
  }
  //support for standalone tags (no {/closing tag} )
  else {
  ereg( (.*), $regs[3], $regs );
  $resolvedTag = getTagValue( $tag );
  $after = $regs[1];
  }
  }
  if( $resolvedTag ) {
  $template =
  $before
  . $resolvedTag
  . $after;
  parse( $template );
  }
  else {
  return $template;
  }
  }
 

 -- 
 Mirek Novak

 jabberID: [EMAIL PROTECTED]
 ICQ: 119499448

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



Re: [PHP] ereg is failing on this simple test

2003-12-13 Thread Eugene Lee
On Fri, Dec 12, 2003 at 07:54:16PM -0800, Manuel Ochoa wrote:
: 
: Why is this test failing?
:  
: $data = A Simple test.;
: If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) {
:   echo Valid text;
: }
: else {
:   echo Not valid text;
: }

You can't use the character class \s within a range.  And you need to
escape a few special characters.  The working version should be:

$data = 'A Simple test.';
#if (ereg(^[a-zA-Z0-9\s.\-_']+$, $data))
if (ereg(^[a-zA-Z0-9[:space:]\.\-_']+$, $data))
{
echo Valid text\n;
}
else
{
echo Not valid text\n;
}

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



RE: [PHP] ereg is failing on this simple test

2003-12-12 Thread Dave G
 Why is this test failing?
 If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) {

I'm very new to PHP, so I may be barking up the wrong tree, but what is
that s doing after the slash? I don't know if it's the cause of the
problem, but as far as I know it's superfluous.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



Re: [PHP] ereg preg

2003-08-15 Thread Curt Zirzow
* Thus wrote Eddy-Das ([EMAIL PROTECTED]):
 is there any syntax difference between
 ereg() and preg() except preg needs / and /?

There are a lot of differences in syntax.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] ereg problem?

2003-07-25 Thread sven
by the way, it's to complicated. the brackets [ and ] are used for
cha-groups. you can leave them for only one char. so this would be the same:
\\n (you have to escape the backslash with a backslash)

Curt Zirzow wrote:
 * Thus wrote John W. Holmes ([EMAIL PROTECTED]):
 [EMAIL PROTECTED] wrote:

 who can tell me what's the pattern string mean.
 if(ereg([\\][n],$username))
 {
   /*Do err*/
 }

 It's looking for a \ character or a \ character followed by the
 letter n anywhere within the string $username.


 I hope that isn't looking for a Carriage Return, cause it never
 will...

 Just in case it is strstr($username, \n);

 Curt



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



RE: [PHP] ereg problem?

2003-07-25 Thread Ford, Mike [LSS]
 -Original Message-
 From: sven [mailto:[EMAIL PROTECTED]
 Sent: 25 July 2003 10:35
 
 by the way, it's to complicated. the brackets [ and ] are used for
 cha-groups. you can leave them for only one char. so this 
 would be the same:
 \\n (you have to escape the backslash with a backslash)

And then we get into the typical
double-quoted-regexp-backslash-proliferation problem -- the above will pass
\n as the regexp, which matches a newline *not* the intended literal \n.  So
now you have to escape the escaped escape, to get:

  n

Which passes \\n as the regexp, which does indeed match a literal \n !

Another way to go is to use single quotes around the regexp, since a
single-quoted string does not interpret \-expressions (except for \', of
course!) -- so this is the same regexp as above:

  '\\n'

I know which I prefer, but YMMV of course!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] ereg problem?

2003-07-24 Thread John W. Holmes
[EMAIL PROTECTED] wrote:

who can tell me what's the pattern string mean.
if(ereg([\\][n],$username))
{
   /*Do err*/
}
It's looking for a \ character or a \ character followed by the letter n 
anywhere within the string $username.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals  www.phparch.com





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


Re: [PHP] ereg problem?

2003-07-24 Thread Curt Zirzow
* Thus wrote John W. Holmes ([EMAIL PROTECTED]):
 [EMAIL PROTECTED] wrote:
 
 who can tell me what's the pattern string mean.
 if(ereg([\\][n],$username))
 {
/*Do err*/
 }
 
 It's looking for a \ character or a \ character followed by the letter n 
 anywhere within the string $username.
 

I hope that isn't looking for a Carriage Return, cause it never will...

Just in case it is strstr($username, \n);

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



RE: [PHP] Ereg question

2003-03-30 Thread John W. Holmes
 I am using ereg to validate the format of a date entry (mm/dd/yy), but
if
 the year ends in a 0, it is being stripped and as such produces an
error.
 So
 1990 would be 199.  The dob is being inputted by a form
 
 Here is my code:
 
 if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob],
$parts))
 {
  $error[dob] = *; $message[dob] = Invalid date format!;
  $dob =  \$parts[3]-$parts[2]-$parts[1]\;
 }

So is $formsave['dob'] being changed before you get to this code,
causing the check to fail? What else are you doing with
$formsave['dob']? Nothing here is going to cause it to drop a zero from
the end. 

Your code doesn't make much sense, though. If the ereg() fails, $parts
is not going to have any value, so why are you referencing $part[1],
$part[2], etc... ?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
$parts has been removed as I found I didn't need it there, but the problem
still exists. This part of code however may be causing the problem, although
I thought trim only stripped white space.?.  $formsave['dob']  is a
session variable.  I have also found now that leading 0's are also being
stripped.

foreach($HTTP_POST_VARS as $varname = $value)
  $formsave[$varname] = trim($value, 50);

If it's not there then the whole script fails.

B.

- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: 'Beauford' [EMAIL PROTECTED]; 'PHP General'
[EMAIL PROTECTED]
Sent: Sunday, March 30, 2003 2:28 PM
Subject: RE: [PHP] Ereg question


  I am using ereg to validate the format of a date entry (mm/dd/yy), but
 if
  the year ends in a 0, it is being stripped and as such produces an
 error.
  So
  1990 would be 199.  The dob is being inputted by a form
 
  Here is my code:
 
  if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob],
 $parts))
  {
   $error[dob] = *; $message[dob] = Invalid date format!;
   $dob =  \$parts[3]-$parts[2]-$parts[1]\;
  }

 So is $formsave['dob'] being changed before you get to this code,
 causing the check to fail? What else are you doing with
 $formsave['dob']? Nothing here is going to cause it to drop a zero from
 the end.

 Your code doesn't make much sense, though. If the ereg() fails, $parts
 is not going to have any value, so why are you referencing $part[1],
 $part[2], etc... ?

 ---John W. Holmes...

 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/



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





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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
This is what I get when I echo $formsave[dob]  - 9/09/199.  It was
inputted as 09/09/1990.

B.

- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: 'Beauford' [EMAIL PROTECTED]; 'PHP General'
[EMAIL PROTECTED]
Sent: Sunday, March 30, 2003 2:28 PM
Subject: RE: [PHP] Ereg question


  I am using ereg to validate the format of a date entry (mm/dd/yy), but
 if
  the year ends in a 0, it is being stripped and as such produces an
 error.
  So
  1990 would be 199.  The dob is being inputted by a form
 
  Here is my code:
 
  if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob],
 $parts))
  {
   $error[dob] = *; $message[dob] = Invalid date format!;
   $dob =  \$parts[3]-$parts[2]-$parts[1]\;
  }

 So is $formsave['dob'] being changed before you get to this code,
 causing the check to fail? What else are you doing with
 $formsave['dob']? Nothing here is going to cause it to drop a zero from
 the end.

 Your code doesn't make much sense, though. If the ereg() fails, $parts
 is not going to have any value, so why are you referencing $part[1],
 $part[2], etc... ?

 ---John W. Holmes...

 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/



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





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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
Just some more information. It appears that the session variable
$formsave[dob] is causing the problem. If I echo the input $_POST['dob']
it shows correctly, but when it's put into $formsave[dob]  the leading and
ending 0's are being stripped.

B.

- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: 'Beauford' [EMAIL PROTECTED]; 'PHP General'
[EMAIL PROTECTED]
Sent: Sunday, March 30, 2003 2:28 PM
Subject: RE: [PHP] Ereg question


  I am using ereg to validate the format of a date entry (mm/dd/yy), but
 if
  the year ends in a 0, it is being stripped and as such produces an
 error.
  So
  1990 would be 199.  The dob is being inputted by a form
 
  Here is my code:
 
  if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob],
 $parts))
  {
   $error[dob] = *; $message[dob] = Invalid date format!;
   $dob =  \$parts[3]-$parts[2]-$parts[1]\;
  }

 So is $formsave['dob'] being changed before you get to this code,
 causing the check to fail? What else are you doing with
 $formsave['dob']? Nothing here is going to cause it to drop a zero from
 the end.

 Your code doesn't make much sense, though. If the ereg() fails, $parts
 is not going to have any value, so why are you referencing $part[1],
 $part[2], etc... ?

 ---John W. Holmes...

 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/



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





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



RE: [PHP] Ereg question

2003-03-30 Thread John W. Holmes
 I thought trim only stripped white space.?.  $formsave['dob']  is
a
 session variable.  I have also found now that leading 0's are also
being
 stripped.
 
 foreach($HTTP_POST_VARS as $varname = $value)
   $formsave[$varname] = trim($value, 50);
 
 If it's not there then the whole script fails.

Why do you have the 50 there in the trim() function? That's what's
causing your problems. You're removing all fives and zeros from the
beginning and end of your string, along with any white space. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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



Re: [PHP] Ereg question

2003-03-30 Thread Jason Wong
On Monday 31 March 2003 04:15, Beauford wrote:
 Just some more information. It appears that the session variable
 $formsave[dob] is causing the problem. If I echo the input $_POST['dob']
 it shows correctly, but when it's put into $formsave[dob]  the leading
 and ending 0's are being stripped.

Having read the whole thread it seems that you're only disclosing information 
when it's been totured out of you :)

May I suggest that in order to save yourself and other people's time that you 
give FULL and ACCURATE information. 

For example, at the start of the thread you're pinning the blame on your ereg, 
then you're saying the session variable is the problem. Only after it has 
been pointed out to you that what you say you're doing cannot possibly have 
the effect that you say you're seeing, do you finally disclose that you're 
using trim() on the vital variables.

Put simply, if you had posted your full and unadulterated code right from the 
start then this thread should/would/could have been resolved in about 2 
posts. Saving time and frustration for everyone involved.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Bit off more than my mind could chew,
Shower or suicide, what do I do?
-- Julie Brown, Will I Make it Through the Eighties?
*/


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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
I posted the information as I had it. I had no idea what the problem was and
posted the information I thought was FULL and ACCURATE - if this isn't good
enough - then maybe I'll look for another list where people are a little
more forgiving of new users. Remember, you were in my shoes once.

B.

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, March 30, 2003 11:20 PM
Subject: Re: [PHP] Ereg question


 On Monday 31 March 2003 04:15, Beauford wrote:
  Just some more information. It appears that the session variable
  $formsave[dob] is causing the problem. If I echo the input
$_POST['dob']
  it shows correctly, but when it's put into $formsave[dob]  the leading
  and ending 0's are being stripped.

 Having read the whole thread it seems that you're only disclosing
information
 when it's been totured out of you :)

 May I suggest that in order to save yourself and other people's time that
you
 give FULL and ACCURATE information.

 For example, at the start of the thread you're pinning the blame on your
ereg,
 then you're saying the session variable is the problem. Only after it has
 been pointed out to you that what you say you're doing cannot possibly
have
 the effect that you say you're seeing, do you finally disclose that you're
 using trim() on the vital variables.

 Put simply, if you had posted your full and unadulterated code right from
the
 start then this thread should/would/could have been resolved in about 2
 posts. Saving time and frustration for everyone involved.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Bit off more than my mind could chew,
 Shower or suicide, what do I do?
 -- Julie Brown, Will I Make it Through the Eighties?
 */


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





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



Re: [PHP] Ereg question

2003-03-30 Thread Jason Wong
On Monday 31 March 2003 13:58, Beauford wrote:

 I posted the information as I had it. I had no idea what the problem was
 and posted the information I thought was FULL and ACCURATE - 

Full and accurate if taken literally are absolute terms and are objective not 
subjective.

 if this isn't
 good enough - then maybe I'll look for another list where people are a
 little more forgiving of new users. Remember, you were in my shoes once.

Jeez, my suggestion was to make it easier for others to help you. If you 
insist you can always continue to post your question in installments (don't 
forget a teaser to whet people's appetite for the next episode). And yes, you 
can also look for another list if you want. These are all your choices.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Things are not always what they seem.
-- Phaedrus
*/


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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
This likely won't get through, but if it does. Post a real address so these
conversations don't go through the list. I mean I'm already a burden to the
list as it is.

B.

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 31, 2003 1:36 AM
Subject: Re: [PHP] Ereg question


 On Monday 31 March 2003 13:58, Beauford wrote:

  I posted the information as I had it. I had no idea what the problem was
  and posted the information I thought was FULL and ACCURATE -

 Full and accurate if taken literally are absolute terms and are objective
not
 subjective.

  if this isn't
  good enough - then maybe I'll look for another list where people are a
  little more forgiving of new users. Remember, you were in my shoes once.

 Jeez, my suggestion was to make it easier for others to help you. If you
 insist you can always continue to post your question in installments
(don't
 forget a teaser to whet people's appetite for the next episode). And yes,
you
 can also look for another list if you want. These are all your choices.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Things are not always what they seem.
 -- Phaedrus
 */


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






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



Re: [PHP] Ereg question

2003-03-30 Thread Peter Houchin
Beauford, Jason,

Build a bridge and get over it already sheeesh

TYVMIA
Peter


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


Re: [PHP] Ereg sass

2003-03-18 Thread Hugh Danaher
try two backslashes to escape php special characters
- Original Message -
From: Liam Gibbs [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 12:33 AM
Subject: [PHP] Ereg sass


I'm not sure why, but I can't include a period in my eregi statement:

[A-Za-z0-9_-.]*

For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in
/home/website/public_html/Functions.inc on line 27

The same goes for [A-Za-z0-9_-\.]*

Anyone know why?



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



Re: [PHP] Ereg sass

2003-03-18 Thread Liam Gibbs
 try two backslashes to escape php special characters

Tried that with the same result.



 I'm not sure why, but I can't include a period in my eregi statement:
 
 [A-Za-z0-9_-.]*
 
 For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in
 /home/website/public_html/Functions.inc on line 27
 
 The same goes for [A-Za-z0-9_-\.]*
 
 Anyone know why?
 
 
 


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



RE: [PHP] Ereg sass[Scanned]

2003-03-18 Thread Michael Egan
Try

[A-Za-z0-9_\-\.]*

-Original Message-
From: Liam Gibbs [mailto:[EMAIL PROTECTED]
Sent: 18 March 2003 08:52
To: php list
Subject: Re: [PHP] Ereg sass[Scanned]


 try two backslashes to escape php special characters

Tried that with the same result.



 I'm not sure why, but I can't include a period in my eregi statement:
 
 [A-Za-z0-9_-.]*
 
 For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in
 /home/website/public_html/Functions.inc on line 27
 
 The same goes for [A-Za-z0-9_-\.]*
 
 Anyone know why?
 
 
 


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


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



Re: [PHP] Ereg sass

2003-03-18 Thread Jason k Larson
It's seeing the - as a range identifier, escape it to get the literal hyphen.

How about this:
[a-zA-Z0-9_\-.]*
In my tests, the period didn't need to be escaped with the \.

HTH,
Jason k Larson
Liam Gibbs wrote:
I'm not sure why, but I can't include a period in my eregi statement:

[A-Za-z0-9_-.]*

For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27

The same goes for [A-Za-z0-9_-\.]*

Anyone know why?



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


Re: [PHP] Ereg sass

2003-03-18 Thread Ernest E Vogelsinger
At 10:36 18.03.2003, Jason k Larson said:
[snip]
It's seeing the - as a range identifier, escape it to get the literal hyphen.

How about this:
[a-zA-Z0-9_\-.]*

In my tests, the period didn't need to be escaped with the \.
[snip] 

The period is a regex placeholder for any character. Thus it will match a
period, but also a #, a @, and everything that's not allowed in the planned
regex.

By escaping the period you're changing the meaning from any character to
or a period (in this context) so I believe that's what you want to do.


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] Ereg sass

2003-03-18 Thread CPT John W. Holmes
If you want to look for a dash (-), you always place it last in the
brackets, other wise the regex machine will be looking for a range. So just
move the - to the last character.

[A-Za-z0-9_.-]*

---John Holmes...

- Original Message -
From: Liam Gibbs [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:33 AM
Subject: [PHP] Ereg sass


I'm not sure why, but I can't include a period in my eregi statement:

[A-Za-z0-9_-.]*

For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in
/home/website/public_html/Functions.inc on line 27

The same goes for [A-Za-z0-9_-\.]*

Anyone know why?


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



Re: [PHP] ereg usage

2003-02-16 Thread Ernest E Vogelsinger
At 16:18 16.02.2003, Peter Gumbrell said:
[snip]
Could someone please tell me why this code is not working:

ereg ('^[A-H]*([0-9]+)-$', $rank, $matches);
$workshop_ID = $matches[1][2};

where $rank is something like C12-1 and I just need the C12 part.
[snip] 

You're missing the -1 part in your expression:

^   Your string begins
[A-H]*  with no or more letters from A to H
([0-9]+)followed by one or more digits (grouped)
-followed by a dash
$ and the end or the string

Your pattern would match C12-, but not C12-1. If you only need the
C12, your pattern should look something like
'^([A-H]*[0-9]+)-'
to return the complete letter/digit sequence at the beginning of the
string, up to (but not including) the dash. Omitting the '$' (string end)
character allows for anything after the dash.


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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




Re: [PHP] ereg usage

2003-02-16 Thread Rick Emery
The problem is that it's looking for hyphen, - , immediately preceeding the end.  
Remove the $.
- Original Message - 
From: Peter Gumbrell [EMAIL PROTECTED]
To: Php-General [EMAIL PROTECTED]
Sent: Sunday, February 16, 2003 9:18 AM
Subject: [PHP] ereg usage


Could someone please tell me why this code is not working:

ereg ('^[A-H]*([0-9]+)-$', $rank, $matches);
$workshop_ID = $matches[1][2};

where $rank is something like C12-1 and I just need the C12 part.

Many thanks

Peter Gumbrell
[EMAIL PROTECTED]


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




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




Re: [PHP] ereg.

2002-12-18 Thread Wico de Leeuw
^ is not in this case
Try
if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) {

Added the $ at the end else the could be more then 20 chars

Greetz

At 17:20 18-12-02 +0100, Anders Thoresson wrote:

What's wrong with the following regular expression? As far as I can se, 
only alphabetic characters including the special swedish ones, should be 
let through, but whatever character passed on in $_REQUEST['f_name'] 
passes the test?

if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) {
error(Your first name should be between 4 and 20 
alphabetic characters);
}

The next one, used to check valid birthday dates, work. And I can't see 
where they differ!

if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday']))

Br,

  Anders


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



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




Re: [PHP] ereg.

2002-12-18 Thread Wico de Leeuw
At 17:26 18-12-02 +0100, Wico de Leeuw wrote:

^ is not in this case


Cancel that, i don't think thats true
anyway

if(!ereg(^[a-zA-ZåÅäÄöÖ]{4,20}\$, $_REQUEST['f_name'])) {

Should work i think

Gr,


Try
if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) {

Added the $ at the end else the could be more then 20 chars

Greetz

At 17:20 18-12-02 +0100, Anders Thoresson wrote:

What's wrong with the following regular expression? As far as I can se, 
only alphabetic characters including the special swedish ones, should be 
let through, but whatever character passed on in $_REQUEST['f_name'] 
passes the test?

if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) {
error(Your first name should be between 4 and 20 
alphabetic characters);
}

The next one, used to check valid birthday dates, work. And I can't see 
where they differ!

if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday']))

Br,

  Anders


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


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




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




Re: [PHP] ereg.

2002-12-18 Thread 1LT John W. Holmes
^ is only NOT when it's the first character within brackets, [ and ]. Also,
don't escape the $ at the end if you really want it to match the end of the
string. Right now your regular expression is matching a literal dollar sign.

As for the original question, it looks correct, providing you can have those
swedish characters in the brackets. What if you just simplify things and
make your ereg look to match a single one of those swedish chacters? Will it
validate correctly if that's all you pass? Play with taking them in and out
and see what works.

---John Holmes...

- Original Message -
From: Wico de Leeuw [EMAIL PROTECTED]
To: Anders Thoresson [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, December 18, 2002 11:26 AM
Subject: Re: [PHP] ereg.


^ is not in this case
Try
if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) {

Added the $ at the end else the could be more then 20 chars

Greetz

At 17:20 18-12-02 +0100, Anders Thoresson wrote:
What's wrong with the following regular expression? As far as I can se,
only alphabetic characters including the special swedish ones, should be
let through, but whatever character passed on in $_REQUEST['f_name']
passes the test?

 if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) {
 error(Your first name should be between 4 and 20
 alphabetic characters);
 }

The next one, used to check valid birthday dates, work. And I can't see
where they differ!

 if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}),
$_REQUEST['birthday']))

Br,

   Anders


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



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


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




Re: [PHP] ereg.

2002-12-18 Thread liljim
Instead of:
(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name']))

Try:
(!ereg(^[a-zA-ZåÅäÄöÖ]{4,20}$, $_REQUEST['f_name']))

(You don't need the brackets unless you're wanting to get the output of the
matches, which in this case, it doesn't look as though you do)

Better still:
(!preg_match(!^[a-zåÅäÄöÖ]{4,20}$!is, $_REQUEST['f_name']))


James

1lt John W. Holmes [EMAIL PROTECTED] wrote in message
002301c2a6b3$a5a695f0$a629089b@TBHHCCDR">news:002301c2a6b3$a5a695f0$a629089b@TBHHCCDR...
 ^ is only NOT when it's the first character within brackets, [ and ].
Also,
 don't escape the $ at the end if you really want it to match the end of
the
 string. Right now your regular expression is matching a literal dollar
sign.

 As for the original question, it looks correct, providing you can have
those
 swedish characters in the brackets. What if you just simplify things and
 make your ereg look to match a single one of those swedish chacters? Will
it
 validate correctly if that's all you pass? Play with taking them in and
out
 and see what works.

 ---John Holmes...

 - Original Message -
 From: Wico de Leeuw [EMAIL PROTECTED]
 To: Anders Thoresson [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, December 18, 2002 11:26 AM
 Subject: Re: [PHP] ereg.


 ^ is not in this case
 Try
 if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) {

 Added the $ at the end else the could be more then 20 chars

 Greetz

 At 17:20 18-12-02 +0100, Anders Thoresson wrote:
 What's wrong with the following regular expression? As far as I can se,
 only alphabetic characters including the special swedish ones, should be
 let through, but whatever character passed on in $_REQUEST['f_name']
 passes the test?
 
  if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) {
  error(Your first name should be between 4 and 20
  alphabetic characters);
  }
 
 The next one, used to check valid birthday dates, work. And I can't see
 where they differ!
 
  if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}),
 $_REQUEST['birthday']))
 
 Br,
 
Anders
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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




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




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




RE: [PHP] ereg() not matching same text each time script is run...

2002-04-23 Thread John Holmes

Someone gave me the preg_match equivalent

preg_match( '/([-_a-z]+)\.([a-z]+)$/i', $row['site'], $match2 );

I tried that and it took care of the problem, as far as I can tell. 

To me, that narrows it down to a problem (bug?) with ereg... anyone else
have any ideas?

---John Holmes...

 -Original Message-
 From: John Holmes [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 23, 2002 6:01 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] ereg() not matching same text each time script is
run...
 
 Okay...I'm really at a loss for this...
 
 (PHP 4.0.6 on Redhat Linux)
 
 I've written a little script that shows the top referrers for
 http://www.falkware.com. Problem is...the script is supposed to take
 www.domain.com and strip out only the domain to show. It does
this,
 but only some of the time. I can't figure out a pattern to it, but
 sometimes the ereg will match domain and sometimes it won't... ??
The
 data is always the same because it's coming from a database. what
gives?
 
 
 Here is the code. This is the same exact code that is running on
 http://www.falkware.com right now. Referrer script is on left hand
side
 near the bottom. Refresh the screen and you'll see how it changes
 (maybe?). You can see I've added in some HTML comments to echo out
what
 the site from the database is, and what was matched.
 
 If anyone can help me out, it's greatly appreciated. I must be going
 crazy or something You can see the same question and code at
 http://forums.devshed.com/showthread.php?s=threadid=34534forumid=5.
 The PHP code has syntax highlighting on it, so it may be easier to
read
 there.
 
 The lines in question are:
 @eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2);
 $name = $match2[1];
 How, if $row[site] is the same because it's pulled from a database,
can
 the ereg match the domain some of the time, and not match it during
 other times...?
 
 

PHP:
 -
 
 //Display table of referers
 $referer_query = SELECT ID, site, count,
 DATE_FORMAT(last_visit,'%c/%e/%y %k:%i') AS last_visit,
 count/(TO_DAYS(NOW()) - TO_DAYS(first_visit)) AS visits_per_day FROM
 $table ORDER BY count DESC LIMIT  . (int)$num_sites;
 $referer_result = DB_query($referer_query);
 
 $returned_rows = DB_numRows($referer_result);
 
 if($returned_rows  0)
 {
 if($_CST_VERBOSE) { COM_errorLog( Displaying top
 $returned_rows Sites , 1); }
 
 
 $retval .= 
 table border='0' cellspacing='0' cellpadding='0'
 align='center' bordercolor='#afae8b' width='98%'
 tr
 td align=centerbfont face='verdana' size='1'
u#/u
 /font/b/td
 td align=centerbfont face='verdana' size='1'
 uSite/u /font/b/td
 td align=centerbfont face='verdana' size='1'
 uHits/u /font/b/td
 /tr
 ;
 
 $site_count = 1;
 
 while($row = DB_fetchArray($referer_result))
 {
 if($_CST_VERBOSE) { COM_errorLog( Displaying Site
 #$site_count, $row[site] , 1); }
 
 unset($match2);
 $retval .= !-- Row[site] ==  . $row[site] .  --;
 
 @eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2);
 $name = $match2[1];
 $retval .= !-- Name matched ==  . $name .  --;
 
 if(strlen($name) == 0)
 {
 $name = $row[site];
 }
 
 $link = http://; . $row[site] . /;
 
 $retval .= 
 tr
 td align=centerfont face='tahoma' size='1'
 color='black'strong $site_count /strong/font/td
 td align=center
 a href='$link' target='_blank'font face='verdana'
 size='1'strong $name /strong/font/a
 /td
 td align='center'font face='verdana'
 size='1'strong $row[count] /strong/font/td
 /tr
 ;
 $site_count++;
 
 if($show_time == 1)
 {
 $retval .= trtd colspan='3' align='right'font
 face='verdana' size='1' color='#99'Last:
 $row[last_visit]/td/tr;
 }
 if($show_posts == 1)
 {
 if($row[visits_per_day] = 0)
 {
 $row[visits_per_day] = $row[count];
 }
 $retval .= trtd colspan='3' align='right'font
 face='verdana' size='1' color='#99'Per Day:
 $row[visits_per_day]/td/tr;
 }
 }
 $retval .= /table;
 }
 else
 {
 $retval .= No referers yet.;
 }
 
 if($_CST_VERBOSE) { COM_errorLog( Leaving
phpblock_top_referer
 in lib-custom.php , 1); }
 
 return $retval;
 


 
 
 When I run the page and look at the source, one time I'll get
 
 !-- Row[site] == www.luclinks.com --!-- Name matched == --
 
 for the comments, and the next time 

Re: [PHP] Ereg ()

2002-04-16 Thread Erik Price


On Tuesday, April 16, 2002, at 08:49  AM, [EMAIL PROTECTED] wrote:


 I'm new with RegEx and I would like to use them to validate my forms
 entries submitted to the server.

 My question is how can I verify with the regex that a string is
 - at least 7 chars
 - contains Chars and Nums
 - may contains some special chars (ex : % ! : ; , )but not in first or 
 last
 position .

I'm assuming that by Chars you mean uppercase/lowercase letters?  
Numbers are characters too, I thought.

preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string);

The above regex will only match a string that begins with A-Z or a-z or 
0-9, then any number of characters that are in the middle character 
class, then a final A-Z or a-z or 0-9.

I think.  Try it out, that's untested.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Ereg ()

2002-04-16 Thread DrouetL


Thanks for this answer.

But how can i test if i actually have numbers AND letters ?

Laurent Drouet



   

Erik Price 

pricee@hhbrow   To: [EMAIL PROTECTED]  

n.com   cc: [EMAIL PROTECTED] 

 Subject: Re: [PHP] Ereg ()

16/04/02 15:44 

   

   






On Tuesday, April 16, 2002, at 08:49  AM, [EMAIL PROTECTED] wrote:


 I'm new with RegEx and I would like to use them to validate my forms
 entries submitted to the server.

 My question is how can I verify with the regex that a string is
 - at least 7 chars
 - contains Chars and Nums
 - may contains some special chars (ex : % ! : ; , )but not in first or
 last
 position .

I'm assuming that by Chars you mean uppercase/lowercase letters?
Numbers are characters too, I thought.

preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string);

The above regex will only match a string that begins with A-Z or a-z or
0-9, then any number of characters that are in the middle character
class, then a final A-Z or a-z or 0-9.

I think.  Try it out, that's untested.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]






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




Re: [PHP] Ereg ()

2002-04-16 Thread Erik Price


On Tuesday, April 16, 2002, at 09:51  AM, [EMAIL PROTECTED] wrote:


 Thanks for this answer.

 But how can i test if i actually have numbers AND letters ?


preg_match('/([A-Za-z].*[\d]|[\d].*[A-Za-z]/', $string);

Untested, but in theory should work.


 On Tuesday, April 16, 2002, at 08:49  AM, [EMAIL PROTECTED] wrote:


 I'm new with RegEx and I would like to use them to validate my forms
 entries submitted to the server.

 My question is how can I verify with the regex that a string is
 - at least 7 chars
 - contains Chars and Nums
 - may contains some special chars (ex : % ! : ; , )but not in first or
 last
 position .

 I'm assuming that by Chars you mean uppercase/lowercase letters?
 Numbers are characters too, I thought.

 preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string);

 The above regex will only match a string that begins with A-Z or a-z or
 0-9, then any number of characters that are in the middle character
 class, then a final A-Z or a-z or 0-9.

 I think.  Try it out, that's untested.


 Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]






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




Re: [PHP] ereg-digits only...

2002-02-12 Thread val petruchek

if ((int($string)==($string))  ($string0)) {then positive integer}

not sure exactly, but try

Valentin Petruchek (aki Zliy Pes)
*** Cut the beginning ***
http://zliypes.com.ua
mailto:[EMAIL PROTECTED]
- Original Message -
From: B. Verbeek [EMAIL PROTECTED]
To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General (E-mail)
[EMAIL PROTECTED]
Sent: Tuesday, February 12, 2002 1:04 PM
Subject: [PHP] ereg-digits only...



 How do I check a string for it to only contain numbers?

 

   if(!ereg(([0-9]+),$string)){

 print It contains characters other than numbers;

   }else{

 print Only numbers;

   }

 

 Can anyone give some feedback...

 regards,
 Bart



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






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




Re: [PHP] ereg-digits only...

2002-02-12 Thread * RzE:

 if ((int($string)==($string))  ($string0)) {then positive integer}
 
 not sure exactly, but try


Why not use the RE's? I usually use preg_* so I'll give the example
using these...


if (preg_match (/^\d+$/, $string)) {
  print (Yep... Only digits.);
} else {
  prnt (Noop! There are non-digit characters...);
}

-- 

* RzE:


-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- 

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




RE: [PHP] ereg-digits only...

2002-02-12 Thread Daniel Kushner

That wouldn't work! 
1) You meant to write: if (((int)$string==$string)  ($string0))

2) (int)'5a' == 5, so this formula would result is 5a == 5!

--Daniel


 -Original Message-
 From: val petruchek [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, February 12, 2002 6:22 AM
 To: [EMAIL PROTECTED]
 Cc: PHP
 Subject: Re: [PHP] ereg-digits only...
 
 
 if ((int($string)==($string))  ($string0)) {then positive integer}
 
 not sure exactly, but try
 
 Valentin Petruchek (aki Zliy Pes)
 *** Cut the beginning ***
 http://zliypes.com.ua
 mailto:[EMAIL PROTECTED]
 - Original Message -
 From: B. Verbeek [EMAIL PROTECTED]
 To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General (E-mail)
 [EMAIL PROTECTED]
 Sent: Tuesday, February 12, 2002 1:04 PM
 Subject: [PHP] ereg-digits only...
 
 
 
  How do I check a string for it to only contain numbers?
 
  
 
if(!ereg(([0-9]+),$string)){
 
  print It contains characters other than numbers;
 
}else{
 
  print Only numbers;
 
}
 
  
 
  Can anyone give some feedback...
 
  regards,
  Bart
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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




Re: [PHP] ereg-digits only...

2002-02-12 Thread val petruchek

as a said before i'm not sure; my idea was to use type casting instead of
eregi;
anyone can develop it into smart solution; i am out of time now for this
developing
so can suggest idea only

Valentin Petruchek (aki Zliy Pes)
*** cUT THE BEGINNING ***
http://zliypes.com.ua
mailto:[EMAIL PROTECTED]
- Original Message -
From: Daniel Kushner [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: PHP [EMAIL PROTECTED]
Sent: Tuesday, February 12, 2002 4:00 PM
Subject: RE: [PHP] ereg-digits only...


 That wouldn't work!
 1) You meant to write: if (((int)$string==$string)  ($string0))

 2) (int)'5a' == 5, so this formula would result is 5a == 5!

 --Daniel


  -Original Message-
  From: val petruchek [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, February 12, 2002 6:22 AM
  To: [EMAIL PROTECTED]
  Cc: PHP
  Subject: Re: [PHP] ereg-digits only...
 
 
  if ((int($string)==($string))  ($string0)) {then positive integer}
 
  not sure exactly, but try
 
  Valentin Petruchek (aki Zliy Pes)
  *** Cut the beginning ***
  http://zliypes.com.ua
  mailto:[EMAIL PROTECTED]
  - Original Message -
  From: B. Verbeek [EMAIL PROTECTED]
  To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General
(E-mail)
  [EMAIL PROTECTED]
  Sent: Tuesday, February 12, 2002 1:04 PM
  Subject: [PHP] ereg-digits only...
 
 
  
   How do I check a string for it to only contain numbers?
  
   
  
 if(!ereg(([0-9]+),$string)){
  
   print It contains characters other than numbers;
  
 }else{
  
   print Only numbers;
  
 }
  
   
  
   Can anyone give some feedback...
  
   regards,
   Bart
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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





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




Re: [PHP] ereg-digits only...

2002-02-12 Thread Lars Torben Wilson

On Tue, 2002-02-12 at 03:04, B. Verbeek wrote:
 
 How do I check a string for it to only contain numbers?
 
  
 
   if(!ereg(([0-9]+),$string)){
 
 print It contains characters other than numbers;
 
   }else{
 
 print Only numbers;
 
   }
 
 
 
 Can anyone give some feedback...
 
 regards,
 Bart

Sure, try is_numeric(): 

  http://www.php.net/is_numeric


Hope this helps,

Torben


-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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




RE: [PHP] ereg et all

2002-01-31 Thread Rick Emery

try:  eregi_replace(this,that,This equals this equals tHis);


-Original Message-
From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 3:40 PM
To: [EMAIL PROTECTED]
Subject: [PHP] ereg et all


hi,

is there a simple way to replace an occurence of a string, into another,
maintaing capital positions...

Like:
$str = This equals this equals tHis;

and I wanna replace all occurences of this in that, that the result will
be:

$str = That equals that equals That;

Edward



-- 
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]




Re: [PHP] ereg et all

2002-01-31 Thread Edward van Bilderbeek - Bean IT

that is not what I meant... I want the cases to remain...

- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 10:47 PM
Subject: RE: [PHP] ereg et all


 try:  eregi_replace(this,that,This equals this equals tHis);


 -Original Message-
 From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 31, 2002 3:40 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] ereg et all


 hi,

 is there a simple way to replace an occurence of a string, into another,
 maintaing capital positions...

 Like:
 $str = This equals this equals tHis;

 and I wanna replace all occurences of this in that, that the result
will
 be:

 $str = That equals that equals That;

 Edward



 --
 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 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 et all

2002-01-31 Thread Jeff Sheltren

I'm not sure why you wanted the last word tHis to be changed to That 
(with a capital)... can you explain further?

Jeff

At 10:52 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
that is not what I meant... I want the cases to remain...

- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 10:47 PM
Subject: RE: [PHP] ereg et all


  try:  eregi_replace(this,that,This equals this equals tHis);
 
 
  -Original Message-
  From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, January 31, 2002 3:40 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] ereg et all
 
 
  hi,
 
  is there a simple way to replace an occurence of a string, into another,
  maintaing capital positions...
 
  Like:
  $str = This equals this equals tHis;
 
  and I wanna replace all occurences of this in that, that the result
will
  be:
 
  $str = That equals that equals That;
 
  Edward
 
 



-- 
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 et all

2002-01-31 Thread Edward van Bilderbeek - Bean IT

Oh, that was a typo... sorry...

it should be:

This equals this equals tHis - That equals that equals tHat

Edward

- Original Message -
From: Jeff Sheltren [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 10:56 PM
Subject: Re: [PHP] ereg et all


 I'm not sure why you wanted the last word tHis to be changed to That
 (with a capital)... can you explain further?

 Jeff

 At 10:52 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
 that is not what I meant... I want the cases to remain...
 
 - Original Message -
 From: Rick Emery [EMAIL PROTECTED]
 To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, January 31, 2002 10:47 PM
 Subject: RE: [PHP] ereg et all
 
 
   try:  eregi_replace(this,that,This equals this equals tHis);
  
  
   -Original Message-
   From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, January 31, 2002 3:40 PM
   To: [EMAIL PROTECTED]
   Subject: [PHP] ereg et all
  
  
   hi,
  
   is there a simple way to replace an occurence of a string, into
another,
   maintaing capital positions...
  
   Like:
   $str = This equals this equals tHis;
  
   and I wanna replace all occurences of this in that, that the
result
 will
   be:
  
   $str = That equals that equals That;
  
   Edward
  
  



 --
 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]




Re: [PHP] ereg et all

2002-01-31 Thread Jeff Sheltren

Ahhh, ok makes more sense now.  Although, I don't think that there is an 
easy way to do what you are asking.  I think that in order to accomplish 
that, you will have to specify all possible cases of a string, and have a 
ereg_replace() statement for each of them.

Jeff

At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
Oh, that was a typo... sorry...

it should be:

This equals this equals tHis - That equals that equals tHat

Edward

- Original Message -
From: Jeff Sheltren [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 10:56 PM
Subject: Re: [PHP] ereg et all


  I'm not sure why you wanted the last word tHis to be changed to That
  (with a capital)... can you explain further?
 
  Jeff



-- 
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 et all

2002-01-31 Thread Edward van Bilderbeek - Bean IT

hmm, that's not what i wanted to hear :-)))

e.g. try doing that for the word: transparancy looots of different
possibilities then...

Edward

- Original Message -
From: Jeff Sheltren [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 11:06 PM
Subject: Re: [PHP] ereg et all


 Ahhh, ok makes more sense now.  Although, I don't think that there is an
 easy way to do what you are asking.  I think that in order to accomplish
 that, you will have to specify all possible cases of a string, and have a
 ereg_replace() statement for each of them.

 Jeff

 At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
 Oh, that was a typo... sorry...
 
 it should be:
 
 This equals this equals tHis - That equals that equals tHat
 
 Edward
 
 - Original Message -
 From: Jeff Sheltren [EMAIL PROTECTED]
 To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, January 31, 2002 10:56 PM
 Subject: Re: [PHP] ereg et all
 
 
   I'm not sure why you wanted the last word tHis to be changed to
That
   (with a capital)... can you explain further?
  
   Jeff





-- 
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 et all - new question..

2002-01-31 Thread Edward van Bilderbeek - Bean IT

Maybe I better ask my question different...

what i want to do is, to highlight certain text in a string...

for example: This equals this equals tHis... has to become:
bThis/b equals bthis/b equals btHis/b... so dispite the case,
the b's should be put around it...

does that make it easier? not for me :-)

Greets,

Edward


- Original Message -
From: Jeff Sheltren [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 11:06 PM
Subject: Re: [PHP] ereg et all


 Ahhh, ok makes more sense now.  Although, I don't think that there is an
 easy way to do what you are asking.  I think that in order to accomplish
 that, you will have to specify all possible cases of a string, and have a
 ereg_replace() statement for each of them.

 Jeff

 At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
 Oh, that was a typo... sorry...
 
 it should be:
 
 This equals this equals tHis - That equals that equals tHat
 
 Edward
 
 - Original Message -
 From: Jeff Sheltren [EMAIL PROTECTED]
 To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, January 31, 2002 10:56 PM
 Subject: Re: [PHP] ereg et all
 
 
   I'm not sure why you wanted the last word tHis to be changed to
That
   (with a capital)... can you explain further?
  
   Jeff





-- 
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 et all - new question..

2002-01-31 Thread Richard Crawford

Seems like that makes it a LOT easier.

Use eregi_relace() instead of ereg_replace().  eregi allows for
case-insensitivity.

Try

eregi_replace(this,b\\1/b,$str);

That should do it, though I haven't tried it myself.


On Thu, 2002-01-31 at 14:14, Edward van Bilderbeek - Bean IT wrote:
 Maybe I better ask my question different...
 
 what i want to do is, to highlight certain text in a string...
 
 for example: This equals this equals tHis... has to become:
 bThis/b equals bthis/b equals btHis/b... so dispite the case,
 the b's should be put around it...
 
 does that make it easier? not for me :-)
 
 Greets,
 
 Edward
 
 
 - Original Message -
 From: Jeff Sheltren [EMAIL PROTECTED]
 To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, January 31, 2002 11:06 PM
 Subject: Re: [PHP] ereg et all
 
 
  Ahhh, ok makes more sense now.  Although, I don't think that there is an
  easy way to do what you are asking.  I think that in order to accomplish
  that, you will have to specify all possible cases of a string, and have a
  ereg_replace() statement for each of them.
 
  Jeff
 
  At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
  Oh, that was a typo... sorry...
  
  it should be:
  
  This equals this equals tHis - That equals that equals tHat
  
  Edward
  
  - Original Message -
  From: Jeff Sheltren [EMAIL PROTECTED]
  To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
  [EMAIL PROTECTED]
  Sent: Thursday, January 31, 2002 10:56 PM
  Subject: Re: [PHP] ereg et all
  
  
I'm not sure why you wanted the last word tHis to be changed to
 That
(with a capital)... can you explain further?
   
Jeff
 
 
 
 
 
 -- 
 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]




Re: [PHP] ereg et all - new question..

2002-01-31 Thread Richard Crawford

Sorry, that should be:

eregi_replace((this),b\\1/b,$str);



On Thu, 2002-01-31 at 14:20, Richard Crawford wrote:
 Seems like that makes it a LOT easier.
 
 Use eregi_relace() instead of ereg_replace().  eregi allows for
 case-insensitivity.
 
 Try
 
   eregi_replace(this,b\\1/b,$str);
 
 That should do it, though I haven't tried it myself.
 
 
 On Thu, 2002-01-31 at 14:14, Edward van Bilderbeek - Bean IT wrote:
  Maybe I better ask my question different...
  
  what i want to do is, to highlight certain text in a string...
  
  for example: This equals this equals tHis... has to become:
  bThis/b equals bthis/b equals btHis/b... so dispite the case,
  the b's should be put around it...
  
  does that make it easier? not for me :-)
  
  Greets,
  
  Edward
  
  
  - Original Message -
  From: Jeff Sheltren [EMAIL PROTECTED]
  To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
  [EMAIL PROTECTED]
  Sent: Thursday, January 31, 2002 11:06 PM
  Subject: Re: [PHP] ereg et all
  
  
   Ahhh, ok makes more sense now.  Although, I don't think that there is an
   easy way to do what you are asking.  I think that in order to accomplish
   that, you will have to specify all possible cases of a string, and have a
   ereg_replace() statement for each of them.
  
   Jeff
  
   At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
   Oh, that was a typo... sorry...
   
   it should be:
   
   This equals this equals tHis - That equals that equals tHat
   
   Edward
   
   - Original Message -
   From: Jeff Sheltren [EMAIL PROTECTED]
   To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
   [EMAIL PROTECTED]
   Sent: Thursday, January 31, 2002 10:56 PM
   Subject: Re: [PHP] ereg et all
   
   
 I'm not sure why you wanted the last word tHis to be changed to
  That
 (with a capital)... can you explain further?

 Jeff
  
  
  
  
  
  -- 
  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 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 et all - new question..

2002-01-31 Thread Edward van Bilderbeek - Bean IT

Wow, thanks a lot...

although it should be \\0 here...

didn't see anything in the manual about the \\ maybe gotta look for it again
:-)

Thanks,

Edward

- Original Message -
From: Richard Crawford [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 11:20 PM
Subject: Re: [PHP] ereg et all - new question..


 Seems like that makes it a LOT easier.

 Use eregi_relace() instead of ereg_replace().  eregi allows for
 case-insensitivity.

 Try

 eregi_replace(this,b\\1/b,$str);

 That should do it, though I haven't tried it myself.


 On Thu, 2002-01-31 at 14:14, Edward van Bilderbeek - Bean IT wrote:
  Maybe I better ask my question different...
 
  what i want to do is, to highlight certain text in a string...
 
  for example: This equals this equals tHis... has to become:
  bThis/b equals bthis/b equals btHis/b... so dispite the
case,
  the b's should be put around it...
 
  does that make it easier? not for me :-)
 
  Greets,
 
  Edward
 
 
  - Original Message -
  From: Jeff Sheltren [EMAIL PROTECTED]
  To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
  [EMAIL PROTECTED]
  Sent: Thursday, January 31, 2002 11:06 PM
  Subject: Re: [PHP] ereg et all
 
 
   Ahhh, ok makes more sense now.  Although, I don't think that there is
an
   easy way to do what you are asking.  I think that in order to
accomplish
   that, you will have to specify all possible cases of a string, and
have a
   ereg_replace() statement for each of them.
  
   Jeff
  
   At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
   Oh, that was a typo... sorry...
   
   it should be:
   
   This equals this equals tHis - That equals that equals tHat
   
   Edward
   
   - Original Message -
   From: Jeff Sheltren [EMAIL PROTECTED]
   To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
   [EMAIL PROTECTED]
   Sent: Thursday, January 31, 2002 10:56 PM
   Subject: Re: [PHP] ereg et all
   
   
 I'm not sure why you wanted the last word tHis to be changed to
  That
 (with a capital)... can you explain further?

 Jeff
  
  
 
 
 
  --
  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]




Re: [PHP] ereg et all - new question..

2002-01-31 Thread Richard Crawford

\\1, actually.  \\0 refers to the entire source string, not just to the
part inside the parentheses... so I think it would put the bold tags
around the entire contents of $str, not just the this words.

At least, that's according to the source I'm using (_Professional PHP
Programming_ by Castagnetto, et al).  YMMV, so you may wish to try it
both ways.


On Thu, 2002-01-31 at 14:23, Edward van Bilderbeek - Bean IT wrote:
 Wow, thanks a lot...
 
 although it should be \\0 here...
 
 didn't see anything in the manual about the \\ maybe gotta look for it again
 :-)
 
 Thanks,
 
 Edward
 
 - Original Message -
 From: Richard Crawford [EMAIL PROTECTED]
 To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Thursday, January 31, 2002 11:20 PM
 Subject: Re: [PHP] ereg et all - new question..
 
 
  Seems like that makes it a LOT easier.
 
  Use eregi_relace() instead of ereg_replace().  eregi allows for
  case-insensitivity.
 
  Try
 
  eregi_replace(this,b\\1/b,$str);
 
  That should do it, though I haven't tried it myself.
 
 
  On Thu, 2002-01-31 at 14:14, Edward van Bilderbeek - Bean IT wrote:
   Maybe I better ask my question different...
  
   what i want to do is, to highlight certain text in a string...
  
   for example: This equals this equals tHis... has to become:
   bThis/b equals bthis/b equals btHis/b... so dispite the
 case,
   the b's should be put around it...
  
   does that make it easier? not for me :-)
  
   Greets,
  
   Edward
  
  
   - Original Message -
   From: Jeff Sheltren [EMAIL PROTECTED]
   To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
   [EMAIL PROTECTED]
   Sent: Thursday, January 31, 2002 11:06 PM
   Subject: Re: [PHP] ereg et all
  
  
Ahhh, ok makes more sense now.  Although, I don't think that there is
 an
easy way to do what you are asking.  I think that in order to
 accomplish
that, you will have to specify all possible cases of a string, and
 have a
ereg_replace() statement for each of them.
   
Jeff
   
At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote:
Oh, that was a typo... sorry...

it should be:

This equals this equals tHis - That equals that equals tHat

Edward

- Original Message -
From: Jeff Sheltren [EMAIL PROTECTED]
To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, January 31, 2002 10:56 PM
Subject: Re: [PHP] ereg et all


  I'm not sure why you wanted the last word tHis to be changed to
   That
  (with a capital)... can you explain further?
 
  Jeff
   
   
  
  
  
   --
   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 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

2002-01-10 Thread Jimmy

Hi Kunal,

 ereg(!--start--(.*)!--stop--, $lineofhtml, $output);

ereg(!--start--([^!--stop--]*)!--stop--, $lineofhtml, $output);

--
Jimmy

It's not what you have in your life that counts, but who you have in your life


-- 
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

2002-01-10 Thread Kunal Jhunjhunwala

Nopes, dint work
Regards,
Kunal Jhunjhunwala
- Original Message -
From: Jimmy [EMAIL PROTECTED]
To: Kunal Jhunjhunwala [EMAIL PROTECTED]
Cc: php-list [EMAIL PROTECTED]
Sent: Friday, January 11, 2002 9:30 AM
Subject: Re: [PHP] ereg


 Hi Kunal,

  ereg(!--start--(.*)!--stop--, $lineofhtml, $output);

 ereg(!--start--([^!--stop--]*)!--stop--, $lineofhtml, $output);

 --
 Jimmy
 
 It's not what you have in your life that counts, but who you have in your
life





-- 
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

2002-01-10 Thread Kunal Jhunjhunwala

RE: [PHP] eregWarning: REG_ERANGE on line 83

83: ereg(!--start--(.*?)!--stop--, $lineofhtml, $output); 
Regards,
Kunal Jhunjhunwala
  - Original Message - 
  From: Martin Towell 
  To: 'Kunal Jhunjhunwala' ; Jimmy 
  Cc: php-list 
  Sent: Friday, January 11, 2002 9:36 AM
  Subject: RE: [PHP] ereg


  what about ? 
  ereg(!--start--(.*?)!--stop--, $lineofhtml, $output); 

  -Original Message- 
  From: Kunal Jhunjhunwala [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, January 11, 2002 3:05 PM 
  To: Jimmy 
  Cc: php-list 
  Subject: Re: [PHP] ereg 



  Nopes, dint work 
  Regards, 
  Kunal Jhunjhunwala 
  - Original Message - 
  From: Jimmy [EMAIL PROTECTED] 
  To: Kunal Jhunjhunwala [EMAIL PROTECTED] 
  Cc: php-list [EMAIL PROTECTED] 
  Sent: Friday, January 11, 2002 9:30 AM 
  Subject: Re: [PHP] ereg 



   Hi Kunal, 
   
ereg(!--start--(.*)!--stop--, $lineofhtml, $output); 
   
   ereg(!--start--([^!--stop--]*)!--stop--, $lineofhtml, $output); 
   
   -- 
   Jimmy 
    
   It's not what you have in your life that counts, but who you have in your 
  life 
   
   
   



  -- 
  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

2002-01-10 Thread Rasmus Lerdorf

.*? is a Perl'ism and only supported by the preg* functions.  Use
preg_match() instead of ereg() and it will work.

-Rasmus

On Fri, 11 Jan 2002, Martin Towell wrote:

 what about ?
 ereg(!--start--(.*?)!--stop--, $lineofhtml, $output);

 -Original Message-
 From: Kunal Jhunjhunwala [mailto:[EMAIL PROTECTED]]
 Sent: Friday, January 11, 2002 3:05 PM
 To: Jimmy
 Cc: php-list
 Subject: Re: [PHP] ereg


 Nopes, dint work
 Regards,
 Kunal Jhunjhunwala
 - Original Message -
 From: Jimmy [EMAIL PROTECTED]
 To: Kunal Jhunjhunwala [EMAIL PROTECTED]
 Cc: php-list [EMAIL PROTECTED]
 Sent: Friday, January 11, 2002 9:30 AM
 Subject: Re: [PHP] ereg


  Hi Kunal,
 
   ereg(!--start--(.*)!--stop--, $lineofhtml, $output);
 
  ereg(!--start--([^!--stop--]*)!--stop--, $lineofhtml, $output);
 
  --
  Jimmy
  
  It's not what you have in your life that counts, but who you have in your
 life
 
 
 


 --
 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]




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 checking if its only numbers

2001-10-05 Thread Rasmus Lerdorf

http://php.net/is_numeric

On Fri, 5 Oct 2001, Chris Aitken wrote:


 Ive been playing around with ereg for about half an hour and having no joy
 because I dont really understand the medhod behind it and how it all works.
 But what im trying to do is check to see if a 9 digit string is all numbers
 and nothing else

 $string1 = 123456789
 $string2 = 123456abc


 how would I check either string with an IF statement and make it continue
 on string 1 (ie, all numbers) and error on string 2 (not all numbers).


 Any suggestions ?



 Thanks


 Chris

 --
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
   __-__
 It is said that if you line up all the cars in the world end to end,
   some moron in a rotary will still to try and pass them





-- 
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 checking if its only numbers

2001-10-05 Thread _lallous

That's not regexps Rasmus! :)
I always see you referring us the the manual! sometimes you refer to a
function i never say in my life! ;)

Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 http://php.net/is_numeric

 On Fri, 5 Oct 2001, Chris Aitken wrote:

 
  Ive been playing around with ereg for about half an hour and having no
joy
  because I dont really understand the medhod behind it and how it all
works.
  But what im trying to do is check to see if a 9 digit string is all
numbers
  and nothing else
 
  $string1 = 123456789
  $string2 = 123456abc
 
 
  how would I check either string with an IF statement and make it
continue
  on string 1 (ie, all numbers) and error on string 2 (not all numbers).
 
 
  Any suggestions ?
 
 
 
  Thanks
 
 
  Chris
 
  --
   Chris Aitken - Administration/Database Designer - IDEAL Internet
email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628
8890
__-__
  It is said that if you line up all the cars in the world end to end,
some moron in a rotary will still to try and pass them
 
 
 




-- 
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 checking if its only numbers

2001-10-04 Thread Jack Dempsey

if(!preg_match(/^\d+$/,$string){
echo $string has something other than a number;
}

-Original Message-
From: Chris Aitken [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 04, 2001 9:34 PM
To: PHP General Mailing List
Subject: [PHP] ereg checking if its only numbers



Ive been playing around with ereg for about half an hour and having no joy
because I dont really understand the medhod behind it and how it all works.
But what im trying to do is check to see if a 9 digit string is all numbers
and nothing else

$string1 = 123456789
$string2 = 123456abc


how would I check either string with an IF statement and make it continue
on string 1 (ie, all numbers) and error on string 2 (not all numbers).


Any suggestions ?



Thanks


Chris

--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
It is said that if you line up all the cars in the world end to end,
  some moron in a rotary will still to try and pass them


--
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]




RE: [PHP] ereg checking if its only numbers

2001-10-04 Thread Maxim Maletsky \(PHPBeginner.com\)

With ereg it could be:

 if(ereg(^[^[:digit:]]+$))
echo 'something else came through';

Untested though ... 

Maxim Maletsky
www.PHPBeginner.com



 -Original Message-
 From: Jack Dempsey [mailto:[EMAIL PROTECTED]] 
 Sent: venerdì 5 ottobre 2001 3.42
 To: Chris Aitken; PHP General Mailing List
 Subject: RE: [PHP] ereg checking if its only numbers
 
 
 if(!preg_match(/^\d+$/,$string){
   echo $string has something other than a number;
 }
 
 -Original Message-
 From: Chris Aitken [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, October 04, 2001 9:34 PM
 To: PHP General Mailing List
 Subject: [PHP] ereg checking if its only numbers
 
 
 
 Ive been playing around with ereg for about half an hour and 
 having no joy because I dont really understand the medhod 
 behind it and how it all works. But what im trying to do is 
 check to see if a 9 digit string is all numbers and nothing else
 
 $string1 = 123456789
 $string2 = 123456abc
 
 
 how would I check either string with an IF statement and make 
 it continue on string 1 (ie, all numbers) and error on string 
 2 (not all numbers).
 
 
 Any suggestions ?
 
 
 
 Thanks
 
 
 Chris
 
 --
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 
 2 4628 8890
   __-__
 It is said that if you line up all the cars in the world 
 end to end,
   some moron in a rotary will still to try and pass them
 
 
 --
 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 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 checking if its only numbers

2001-10-04 Thread Evan

try:

?
if(ereg([0-9]{9}, $string)){
echo Success, 9 numbers!;
} else {
echo Failure, not 9 numbers.;
}
?

There is a great book on regular expressions by o'reily.

Evan

*** REPLY SEPARATOR  ***

On 10/5/01 at 11:33 AM Chris Aitken wrote:

Ive been playing around with ereg for about half an hour and having no
joy
because I dont really understand the medhod behind it and how it all
works.
But what im trying to do is check to see if a 9 digit string is all
numbers
and nothing else

$string1 = 123456789
$string2 = 123456abc


how would I check either string with an IF statement and make it continue
on string 1 (ie, all numbers) and error on string 2 (not all numbers).


Any suggestions ?



Thanks


Chris

--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
It is said that if you line up all the cars in the world end to end,
  some moron in a rotary will still to try and pass them


--
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]




Re: [PHP] ereg

2001-09-30 Thread ReDucTor

use MSIE:[56|5\..|6\..] something like that, i suck at regular expression :D
- Original Message - 
From: Matthew Delmarter [EMAIL PROTECTED]
To: PHP Mailing List [EMAIL PROTECTED]
Sent: Monday, October 01, 2001 1:32 PM
Subject: [PHP] ereg


 How do I use ereg to check for MSIE 5.5 and above.
 
 eg: eregi((MSIE.[56]),$HTTP_USER_AGENT)
 
 This only gets version 5 and 6 ... but I want 5.5 and above. Any
 ideas?
 
 Regards,
 
 Matthew Delmarter
 
 
 -- 
 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]




Re: [PHP] ereg question

2001-09-02 Thread Papp Gyozo

Hello,

check it in the manual: http://www.php.net/manual/en/function.ereg.php

If you don't pass the third -- optional -- argument, then it's true.
Otherwise not.

I don't know this book, but you may keep in my mind that PHP is evolving,
so the online manual can be its most up-to-date documentation.

- Original Message -
From: js [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, September 02, 2001 3:05 AM
Subject: [PHP] ereg question


 In the Leon Atkinson Core PHP book, in his ereg example he states that
ereg
 will only return the first match on a line.  Can anyone confirm or deny
this?

 Thanks,
 Josh


 --
 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]




Re: [PHP] ereg()

2001-08-28 Thread Jack Dempsey

You could try fgets from the fp instead of fread. Then for each line depending
on how well structured it is you have a variety of options, but i think this
would be at least a good start:
www.php.net/preg_split - split on multiple spaces - \s+

jack

Ben Quinn wrote:

 Hi all

 Say i had text similar to below

 Cairns  Fine
 Mareeba Fine
 Innisfail   Fine

 I'm using the following code to grab the weather forecast for each of those
 towns

 $GrabURL = forecast_map_data.txt;
 $GrabStart = PROVINCIAL CITY;
 $GrabEnd = UV ratings;

 $file = fopen($GrabURL, r);
 $rf = fread($file, 2);
 $grab = eregi($GrabStart(.*)$GrabEnd, $rf, $show);

 eregi(Cairns(.*)Mareeba, $show[1], $cairns);

 which works fine, but when i then try to grab the forecast for Mareeba using
 this

 eregi(Mareeba(.*)Innisfail, $show[1], $mareeba);

 nothing happens - i figure it's because i've already use Mareeba as a stop
 point.  Can anyone recommend a function or a way to do this where i'll be
 able to use the same start or stop text more than once?

 --
 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]



Ben Quinn wrote:

 Hi all

 Say i had text similar to below

 Cairns  Fine
 Mareeba Fine
 Innisfail   Fine

 I'm using the following code to grab the weather forecast for each of those
 towns

 $GrabURL = forecast_map_data.txt;
 $GrabStart = PROVINCIAL CITY;
 $GrabEnd = UV ratings;

 $file = fopen($GrabURL, r);
 $rf = fread($file, 2);
 $grab = eregi($GrabStart(.*)$GrabEnd, $rf, $show);

 eregi(Cairns(.*)Mareeba, $show[1], $cairns);

 which works fine, but when i then try to grab the forecast for Mareeba using
 this

 eregi(Mareeba(.*)Innisfail, $show[1], $mareeba);

 nothing happens - i figure it's because i've already use Mareeba as a stop
 point.  Can anyone recommend a function or a way to do this where i'll be
 able to use the same start or stop text more than once?

 --
 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]




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]




Re: [PHP] ereg parse error problem

2001-07-12 Thread Philip Murray

Hi Lara,

The problem isn't with the if(ereg) line, its the line above.

Put a semi-colon at the end of your $string = ..[snip].. line

Cheers

 -  -- -  -   -
Philip Murray - Senior Systems Engineer
[EMAIL PROTECTED] - Open2View.com
http://www.open2view.com
- -  -- -   -

- Original Message -
From: Lara J. Fabans [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 13, 2001 1:59 PM
Subject: [PHP] ereg parse error problem


 Hi, friends,

 I'm receiving a parse error on the if (ereg... )
 lines of this code.  I looked at the online manual and modeled my two
 ereg's after it.
 When I kept getting parse errors, I decided to copy the original from the
 manual into
 my code, and it too received a parse error.

 Can someone please help me resolve this?

 Thank you,

 Lara


 -
 ?php

 $string = lt;a href=quot;http://www.qksrv.net/click-297915-361662quot;
 target=quot;_topquot; gt; lt;img
 src=quot;http://www.123posters.com/images/m-mase01.jpgquot;
 alt=quot;Mase Necklacequot;gt;lt;/agt; lt;img
 src=quot;http://www.qksrv.net/image-297915-361662quot;
 height=quot;1quot; width=quot;1quot; border=quot;0quot;gt;

 if (ereg (([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}), $string, $regs))
 {
  echo $regs[3].$regs[2].$regs[1];
 } else {
  echo Invalid date format: $date;
 }


 if (ereg (img src=quot;(.*)quot;, $string, $regs))
 {
 echo $regs[1];
 } else
 {
 echo nope1;
 }

 if (eregi(a href=quot;(.*)quot;, $string, $regs))
 {
 echo $regs[1];
 } else
 {
 echo nope2;
 }
 ?
 -
 Lara J. Fabans
 Lodestone Software, Inc
 [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 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 questions

2001-05-24 Thread Dan Lowe

Previously, Ker Ruben Ramos said:
 hmm, got a little question.
 1. what's that \\1 and \\2? got any info on where u got that from?

Expands to whatever the parentheses surrounded during the match.  So
in this case you have:

Match pattern:  a href=\([^/]+)/(.*)\\.html\
Replace pattern:a href=\file.php?file=\\1\\2.php\

There are two places in the match pattern where there are ().  These are
memorized (rather whatever they actually matched was memorized) and then
you can spit it back out in the replacement pattern using \\1, \\2, etc.

 -dan

 2. what if it's just href=anything.html ? i mean.. something like it got
 lots of subdirectories or not.
 
 Thanks
 - Original Message -
 From: Mark Maggelet [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, May 24, 2001 1:19 AM
 Subject: Re: [PHP] ereg questions
 
 
  On Thu, 24 May 2001 01:01:16 +0800, Ker Ruben Ramos
  ([EMAIL PROTECTED]) wrote:
  How do i change all 'a href=anything/here.html' to 'a
  href=file.php?file=anythinghere.php'
  any help out there?
 
  I would go:
 
  $string = ereg_replace(
  a href=\([^/]+)/(.*)\\.html\,
  a href=\file.php?file=\\1\\2.php\,
  $string);
 
  - Mark
 
 
 
 
 
 -- 
 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]

-- 
If carpenters made buildings the way programmers make programs, the first
woodpecker to come along would destroy all of civilization.
-Weinberg's Second Law

-- 
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 questions

2001-05-24 Thread Ker Ruben Ramos

Thanks alot, now i know what are thos \\$NUM
but one more thing, where're those \\0 come from? just found it on some
scripts using \\0. seems to confuse me a bit.

Thanks
- Original Message -
From: Dan Lowe [EMAIL PROTECTED]
To: Ker Ruben Ramos [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, May 24, 2001 5:18 PM
Subject: Re: [PHP] ereg questions


 Previously, Ker Ruben Ramos said:
  hmm, got a little question.
  1. what's that \\1 and \\2? got any info on where u got that from?

 Expands to whatever the parentheses surrounded during the match.  So
 in this case you have:

 Match pattern:  a href=\([^/]+)/(.*)\\.html\
 Replace pattern: a href=\file.php?file=\\1\\2.php\

 There are two places in the match pattern where there are ().  These are
 memorized (rather whatever they actually matched was memorized) and then
 you can spit it back out in the replacement pattern using \\1, \\2, etc.

  -dan

  2. what if it's just href=anything.html ? i mean.. something like it
got
  lots of subdirectories or not.
 
  Thanks
  - Original Message -
  From: Mark Maggelet [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, May 24, 2001 1:19 AM
  Subject: Re: [PHP] ereg questions
 
 
   On Thu, 24 May 2001 01:01:16 +0800, Ker Ruben Ramos
   ([EMAIL PROTECTED]) wrote:
   How do i change all 'a href=anything/here.html' to 'a
   href=file.php?file=anythinghere.php'
   any help out there?
  
   I would go:
  
   $string = ereg_replace(
   a href=\([^/]+)/(.*)\\.html\,
   a href=\file.php?file=\\1\\2.php\,
   $string);
  
   - Mark
  
  
  
 
 
  --
  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]

 --
 If carpenters made buildings the way programmers make programs, the first
 woodpecker to come along would destroy all of civilization.
 -Weinberg's Second Law



-- 
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 function

2001-05-24 Thread CC Zona

In article 002e01c0e46c$ec2459a0$6e00a8c0@webdesign,
 [EMAIL PROTECTED] (Jay Paulson) wrote:

 echo ereg(^[a-zA-Z]$, $fname);
 
 as you can see I'm just looking to make sure the variable $fname just has 
 characters a-zA-Z and nothing else.

Actually, you're checking whethere the variable is a single-character 
string a-zA-Z.  For what you want:

ereg(^[a-zA-Z]+$, $fname); //add plus sign

Note also that although the docs imply that ereg() returns an integer 
value, it says further down Returns true if a match for pattern was found 
in string, or false if no matches were found or an error occurred.  In my 
experience, boolean values don't echo well.  Try this instead:

if(ereg(^[a-zA-Z]+$, $fname))
   {
   echo pPassed!/p\n;
   }
 else
   {
   echo pFailed.  Enter a different value./p\n;
   }

-- 
CC

-- 
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 questions

2001-05-23 Thread Ker Ruben Ramos

hmm, got a little question.
1. what's that \\1 and \\2? got any info on where u got that from?
2. what if it's just href=anything.html ? i mean.. something like it got
lots of subdirectories or not.

Thanks
- Original Message -
From: Mark Maggelet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 24, 2001 1:19 AM
Subject: Re: [PHP] ereg questions


 On Thu, 24 May 2001 01:01:16 +0800, Ker Ruben Ramos
 ([EMAIL PROTECTED]) wrote:
 How do i change all 'a href=anything/here.html' to 'a
 href=file.php?file=anythinghere.php'
 any help out there?

 I would go:

 $string = ereg_replace(
 a href=\([^/]+)/(.*)\\.html\,
 a href=\file.php?file=\\1\\2.php\,
 $string);

 - Mark





-- 
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 issues

2001-05-10 Thread ..s.c.o.t.t.. [gts]

print preg_replace('/(.*?)(\w{2})(.*)/', '\\2', $blah);

works for:

$blah = *9 scott 777zxsdf;
and
$blah = scott;


 -Original Message-
 From: Jerry Lake [mailto:[EMAIL PROTECTED]]
 Subject: [PHP] ereg issues
 
 I'm feeling a bit stupid today
 how do I truncate a string to the
 first two [a-zA-Z] characters ?
 
 this sure isn't working
 snip
 $test = jerry;
 $test = ereg_replace(^\w*, ^[a-zA-Z]{2} ,$test);
 /snip


-- 
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 issues

2001-05-10 Thread scott [gts]

oh yeah.  sorry...

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jack
 Dempsey
 Sent: Thursday, May 10, 2001 3:15 PM
 To: ..s.c.o.t.t.. [gts]
 Cc: Php-General
 Subject: Re: [PHP] ereg issues
 
 
 isn't a \w a word character, meaning a-zA-Z_0-9 (in perl)?
 if so, that wouldn't match the a-zA-z he originally intended...
 am i missing something?
 
 -jack
 
 ..s.c.o.t.t.. [gts] wrote:
  
  print preg_replace('/(.*?)(\w{2})(.*)/', '\\2', $blah);
  
  works for:
  
  $blah = *9 scott 777zxsdf;
  and
  $blah = scott;
  
   -Original Message-
   From: Jerry Lake [mailto:[EMAIL PROTECTED]]
   Subject: [PHP] ereg issues
  
   I'm feeling a bit stupid today
   how do I truncate a string to the
   first two [a-zA-Z] characters ?
  
   this sure isn't working
   snip
   $test = jerry;
   $test = ereg_replace(^\w*, ^[a-zA-Z]{2} ,$test);
   /snip
  
  --
  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 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 issues

2001-05-10 Thread Jack Dempsey

print preg_replace('/^(.*?)([a-zA-Z]{2})(.*)/','\\2',$blah);

try that

-jack

scott [gts] wrote:
 
 oh yeah.  sorry...
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jack
  Dempsey
  Sent: Thursday, May 10, 2001 3:15 PM
  To: ..s.c.o.t.t.. [gts]
  Cc: Php-General
  Subject: Re: [PHP] ereg issues
 
 
  isn't a \w a word character, meaning a-zA-Z_0-9 (in perl)?
  if so, that wouldn't match the a-zA-z he originally intended...
  am i missing something?
 
  -jack
 
  ..s.c.o.t.t.. [gts] wrote:
  
   print preg_replace('/(.*?)(\w{2})(.*)/', '\\2', $blah);
  
   works for:
  
   $blah = *9 scott 777zxsdf;
   and
   $blah = scott;
  
-Original Message-
From: Jerry Lake [mailto:[EMAIL PROTECTED]]
Subject: [PHP] ereg issues
   
I'm feeling a bit stupid today
how do I truncate a string to the
first two [a-zA-Z] characters ?
   
this sure isn't working
snip
$test = jerry;
$test = ereg_replace(^\w*, ^[a-zA-Z]{2} ,$test);
/snip
  
   --
   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 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]




RE: [PHP] ereg issues

2001-05-10 Thread Jerry Lake

Cool, thanks

Jerry Lake
Interface Engineering Technician
Europa Communications - http://www.europa.com
Pacifier Online - http://www.pacifier.com


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jack
Dempsey
Sent: Thursday, May 10, 2001 12:39 PM
To: scott [gts]
Cc: Php-General
Subject: Re: [PHP] ereg issues


print preg_replace('/^(.*?)([a-zA-Z]{2})(.*)/','\\2',$blah);

try that

-jack

scott [gts] wrote:

 oh yeah.  sorry...

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jack
  Dempsey
  Sent: Thursday, May 10, 2001 3:15 PM
  To: ..s.c.o.t.t.. [gts]
  Cc: Php-General
  Subject: Re: [PHP] ereg issues
 
 
  isn't a \w a word character, meaning a-zA-Z_0-9 (in perl)?
  if so, that wouldn't match the a-zA-z he originally intended...
  am i missing something?
 
  -jack
 
  ..s.c.o.t.t.. [gts] wrote:
  
   print preg_replace('/(.*?)(\w{2})(.*)/', '\\2', $blah);
  
   works for:
  
   $blah = *9 scott 777zxsdf;
   and
   $blah = scott;
  
-Original Message-
From: Jerry Lake [mailto:[EMAIL PROTECTED]]
Subject: [PHP] ereg issues
   
I'm feeling a bit stupid today
how do I truncate a string to the
first two [a-zA-Z] characters ?
   
this sure isn't working
snip
$test = jerry;
$test = ereg_replace(^\w*, ^[a-zA-Z]{2} ,$test);
/snip
  
   --
   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 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 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]




  1   2   >