[PHP] Re: string search

2001-07-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (J Smith) wrote:

> > I need a search function (if statement) that performs a search on a string
> > and if the string contains something like "aol.com", performs another
> > function. Can anyone help me? Thanks.
> > 
> > Joseph
> > 
> 
> Try researching regular expressions. In PHP, look at the preg and ereg 
> groups of functions.

This doesn't sound like it requires the overhead of a regex function.  
Check out  instead.

-- 
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] RE: string search

2001-07-16 Thread scott [gts]

hehe... that's what regular expressions are for.
they're extrememly powerful... but that doesnt mean that
you should only use them for extremely complicated situations.
they work great everywhere... 

if you dont like "overdoing it", you might as well loop
thru the string character by character, C-style.  :-)

> -Original Message-
> From: Sheridan Saint-Michel [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] RE: string search
> 
> Couldn't he just do something like
> 
> if (strstr($text, "aol.com")) {
>MyFunction();
> } else {
>echo "Not Found";
> }
> 
> It just seems like using ereg for this is like killing a fly with a
> sledgehammer
> 
> Sheridan


-- 
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] RE: string search

2001-07-16 Thread Sheridan Saint-Michel

Couldn't he just do something like

if (strstr($text, "aol.com")) {
   MyFunction();
} else {
   echo "Not Found";
}

It just seems like using ereg for this is like killing a fly with a
sledgehammer

Sheridan

- Original Message -
From: scott [gts] <[EMAIL PROTECTED]>
To: php <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 10:59 AM
Subject: RE: [PHP] RE: string search


> read the docs for ereg... i hardly use it, so i dont know
> for certain if it will match. (althouth the use of "^" at
> beginning *and* end suggests that it wont do what you expect)
>
> preg will match "aol.com" with this regexp:
>
> preg_match('/aol.com/', $string )
>
>
> > -Original Message-
> > From: Joseph Bannon [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 16, 2001 11:49 AM
> > To: PHP (E-mail)
> > Subject: [PHP] RE: string search
> >
> >
> > Will this work?
> >
> > $string = "http://www.aol.com/";;
> >
> > if (ereg ("^aol.com^", $string) {
> > }
> > else {
> > }
>
>
> --
> 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] RE: string search

2001-07-16 Thread scott [gts]

read the docs for ereg... i hardly use it, so i dont know
for certain if it will match. (althouth the use of "^" at
beginning *and* end suggests that it wont do what you expect)

preg will match "aol.com" with this regexp:

preg_match('/aol.com/', $string )


> -Original Message-
> From: Joseph Bannon [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 11:49 AM
> To: PHP (E-mail)
> Subject: [PHP] RE: string search
> 
> 
> Will this work?
> 
> $string = "http://www.aol.com/";;
> 
> if (ereg ("^aol.com^", $string) {
> }
> else {
> }


-- 
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] RE: string search

2001-07-16 Thread Joseph Bannon

Will this work?

$string = "http://www.aol.com/";;

if (ereg ("^aol.com^", $string) {
}
else {
}



> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
















-- 
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] Re: string search

2001-07-16 Thread Steve Brett

have a look at ereg() (regular expression match)  functions in manual.
they'll do exactly what you want.

Steve

"Joseph Bannon" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
>
> Joseph



-- 
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] Re: string search

2001-07-16 Thread J Smith

Joseph Bannon wrote:

> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
> 
> Joseph
> 

Try researching regular expressions. In PHP, look at the preg and ereg 
groups of functions.

J

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