Re: [PHP] still not friends with RegExps..

2001-05-22 Thread Dan Lowe

Previously, Zef Hemel said:
> $string = preg_replace("/[\\\*\+\-;]/s","",$string);
> 
> I think, you might have to escape the ; too

You don't need to escape * or + inside a character class since they don't
have a special meaning inside a character class.

You will need to use '' to match a backslash, however.  And if you move
the hypen to the last position in the character class, it loses its magic
property as a range specifier and no longer needs to be quoted either.

This should do what you want:

$string = preg_replace("/[;*+-]/s", "", $string);

 -dan

-- 
The process for understanding customers primarily involves sitting around
with other marketing people and talking about what you would to if you were
dumb enough to be a customer.  -Scott Adams, "The Dilbert Principle"

-- 
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] still not friends with RegExps..

2001-05-16 Thread scott [gts]

yes... i agree.

if you know pregs, you have the added benefit of
knowing how to write regexps for PHP *and* perl
(should you ever have to program in perl)

i personally prefer pregs becuase i think that the
syntax is cleaner and more concise...

> -Original Message-
> From: Christian Reiniger [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] still not friends with RegExps..
> 
> 
> On Tuesday 15 May 2001 22:35, Gyozo Papp wrote:
> > I mean that it seems to me most of the mailers use preg funtions
> > instead of simple ereg functions. Up to now I used only the latter
> > ones.
> 
> Well, actually preg is more simple IMHO :)
> Anyway - preg are the Perl-style regexps, so any perl regular expression 
> documentation should be fine. Also the "preg expression syntax" page in 
> the manual is very good.

-- 
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] still not friends with RegExps..

2001-05-16 Thread Christian Reiniger

On Tuesday 15 May 2001 22:35, Gyozo Papp wrote:
> I mean that it seems to me most of the mailers use preg funtions
> instead of simple ereg functions. Up to now I used only the latter
> ones.

Well, actually preg is more simple IMHO :)
Anyway - preg are the Perl-style regexps, so any perl regular expression 
documentation should be fine. Also the "preg expression syntax" page in 
the manual is very good.

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"Software is like sex: the best is for free" -- Linus Torvalds

--
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] still not friends with RegExps..

2001-05-15 Thread Gyozo Papp

I mean that it seems to me most of the mailers use preg funtions instead of simple 
ereg functions.
Up to now I used only the latter ones.
I still know where I can find documantation, I just go further and ask some link to 
learn more about 
PCRE functions.

I'm sorry if you misunderstand it.

- Original Message - 
From: "CC Zona" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 15. 22:19
Subject: Re: [PHP] still not friends with RegExps..


> In article <025c01c0dd7a$3b75d320$6a45c5d5@jaguar>,
>  [EMAIL PROTECTED] ("Gyozo Papp") wrote:
> 
> > > > There is a function quotemeta() which escapes all special regexp 
> > > > character 
> > > > such as:
> > > > . \ + * ? [ ^ ] ( $ )
> > > > with a '\' except one the  '|' pipe.
> > > 
> > > Forget quotemeta().  Use preg quote() instead.
> >
> > Ok, now it's time to get familiar with preg?
> 
> No, now it's time to get familiar with the online manual 
> <http://php.net/pgre-quote>, where you would quickly discover that 
> preg_quote can be used even by somone with zero knowledge of PCRE syntax.
> 
> -- 
> 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]
> 


--
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] still not friends with RegExps..

2001-05-15 Thread CC Zona

In article <025c01c0dd7a$3b75d320$6a45c5d5@jaguar>,
 [EMAIL PROTECTED] ("Gyozo Papp") wrote:

> > > There is a function quotemeta() which escapes all special regexp 
> > > character 
> > > such as:
> > > . \ + * ? [ ^ ] ( $ )
> > > with a '\' except one the  '|' pipe.
> > 
> > Forget quotemeta().  Use preg quote() instead.
>
> Ok, now it's time to get familiar with preg?

No, now it's time to get familiar with the online manual 
, where you would quickly discover that 
preg_quote can be used even by somone with zero knowledge of PCRE syntax.

-- 
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] still not friends with RegExps..

2001-05-15 Thread Jack Dempsey

If you intend on using regex's intensively (or at all really) do yourself a
favor and get mastering regular expressions from o'reilly...it has more than
you'll probably care to know at first, but so many good examples, and such a
detailed analysis, that you'll become really comfortable and won't playing
the guessing that i for one used to...

-jack

-Original Message-
From: Gyozo Papp [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 4:04 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] still not friends with RegExps..


Ok, now it's time to get familiar with preg?

If this stands, can you give me a link  to a good tutorial with tons of
examples beside the PHP manual?
The most effective way to learn is to see how it works, I think.

- Original Message -
From: "CC Zona" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 15. 21:43
Subject: Re: [PHP] still not friends with RegExps..


> In article <00c301c0dd69$a64de040$6a45c5d5@jaguar>,
>  [EMAIL PROTECTED] ("Gyozo Papp") wrote:
>
> > There is a function quotemeta() which escapes all special regexp
character
> > such as:
> > . \ + * ? [ ^ ] ( $ )
> > with a '\' except one the  '|' pipe.
>
> Forget quotemeta().  Use preg_quote() 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]
>


--
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] still not friends with RegExps..

2001-05-15 Thread Gyozo Papp

Ok, now it's time to get familiar with preg?

If this stands, can you give me a link  to a good tutorial with tons of examples 
beside the PHP manual?
The most effective way to learn is to see how it works, I think.

- Original Message - 
From: "CC Zona" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 15. 21:43
Subject: Re: [PHP] still not friends with RegExps..


> In article <00c301c0dd69$a64de040$6a45c5d5@jaguar>,
>  [EMAIL PROTECTED] ("Gyozo Papp") wrote:
> 
> > There is a function quotemeta() which escapes all special regexp character 
> > such as:
> > . \ + * ? [ ^ ] ( $ )
> > with a '\' except one the  '|' pipe.
> 
> Forget quotemeta().  Use preg_quote() 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]
> 


--
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] still not friends with RegExps..

2001-05-15 Thread CC Zona

In article <00c301c0dd69$a64de040$6a45c5d5@jaguar>,
 [EMAIL PROTECTED] ("Gyozo Papp") wrote:

> There is a function quotemeta() which escapes all special regexp character 
> such as:
> . \ + * ? [ ^ ] ( $ )
> with a '\' except one the  '|' pipe.

Forget quotemeta().  Use preg_quote() 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] still not friends with RegExps..

2001-05-15 Thread Gyozo Papp

Hello,

while I was reading the post from 'elias', a fairly old question came in my mind which 
I've not get any answer yet.
Maybe you can do it.

There is a function quotemeta() which escapes all special regexp character such as:
. \ + * ? [ ^ ] ( $ )
with a '\' except one the  '|' pipe.

what reason for this behaviour?

- Original Message - 
From: "Taylor, Stewart" <[EMAIL PROTECTED]>
To: "'elias'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: 2001. május 15. 15:16
Subject: RE: [PHP] still not friends with RegExps..


> preg_replace does not seem to agree with '\\'.
> Below seems to work with ereg_replace.
> 
>  $pat = "[*+;\\-]";
> $rep = " ";
> echo ereg_replace($pat,$rep,$string);
> ?>
> 
> -Stewart
> ~
> 
> -Original Message-
> From: elias [mailto:[EMAIL PROTECTED]]
> Sent: 15 May 2001 23:37
> To: [EMAIL PROTECTED]
> Subject: [PHP] still not friends with RegExps..
> 
> 
> Hello,
> 
> Maybe RegExps are still my point of weakness...but I still like them as much
> as I like the Self-Reference phrases...
> 
> Okay now, how can i replace all the matches of "\" , "*", "+", "-" and ";"
> with an empty string by calling once the preg_replace() or str_replace() or
> any string replace function? ("")
> 
> Do i have to call it as many times as i got different replacments?
> 
> -elias
> 
> 
> 
> 
> -- 
> 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] still not friends with RegExps..

2001-05-15 Thread Taylor, Stewart

preg_replace does not seem to agree with '\\'.
Below seems to work with ereg_replace.



-Stewart
~

-Original Message-
From: elias [mailto:[EMAIL PROTECTED]]
Sent: 15 May 2001 23:37
To: [EMAIL PROTECTED]
Subject: [PHP] still not friends with RegExps..


Hello,

Maybe RegExps are still my point of weakness...but I still like them as much
as I like the Self-Reference phrases...

Okay now, how can i replace all the matches of "\" , "*", "+", "-" and ";"
with an empty string by calling once the preg_replace() or str_replace() or
any string replace function? ("")

Do i have to call it as many times as i got different replacments?

-elias




-- 
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] still not friends with RegExps..

2001-05-15 Thread Zef Hemel

$string = preg_replace("/[\\\*\+\-;]/s","",$string);

I think, you might have to escape the ; too

Zef


"elias" <[EMAIL PROTECTED]> schreef in berichtnieuws
9dr733$knl$[EMAIL PROTECTED]
> Hello,
>
> Maybe RegExps are still my point of weakness...but I still like them as
much
> as I like the Self-Reference phrases...
>
> Okay now, how can i replace all the matches of "\" , "*", "+", "-" and ";"
> with an empty string by calling once the preg_replace() or str_replace()
or
> any string replace function? ("")
>
> Do i have to call it as many times as i got different replacments?
>
> -elias
>
>
>
>
> --
> 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]