[PHP] Is there a faster way to escape special characters in a regex?

2002-03-12 Thread Richard Davey
Hi all, At the moment I'm doing this to escape all special regular expression characters from my regex string: $badwordtest = str_replace(/,,$badwordtest); $badwordtest = str_replace(\\,,$badwordtest); $badwordtest = str_replace(^,\^,$badwordtest); $badwordtest =

Re: [PHP] Is there a faster way to escape special characters in a regex?

2002-03-12 Thread Andrey Hristov
In PHP 4.0.5 and later, every parameter to str_replace() can be an array.If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of

Re: [PHP] Is there a faster way to escape special characters in a regex?

2002-03-12 Thread Richard Davey
Andrey Hristov [EMAIL PROTECTED] wrote in message 053801c1c9d0$5b4da400$0b01a8c0@ANDreY">news:053801c1c9d0$5b4da400$0b01a8c0@ANDreY... In PHP 4.0.5 and later, every parameter to str_replace() can be an array.If search and Thank you for pointing that out :) I've now changed my code from the

Re: [PHP] Is there a faster way to escape special characters in a regex?

2002-03-12 Thread Andrey Hristov
Yes they are identical. The rule is that the first and the last(excluding modificators) symbol must be identical so |abc| ~abc~ /abc/ %abc%(not sure for that) are equivalent. The docs uses // syntax because it is the most popular. Regards, Andrey Hristov - Original Message - From:

Re: [PHP] Is there a faster way to escape special characters in a regex?

2002-03-12 Thread Jason Wong
On Tuesday 12 March 2002 22:30, Andrey Hristov wrote: Yes they are identical. The rule is that the first and the last(excluding modificators) symbol must be identical so |abc| ~abc~ /abc/ %abc%(not sure for that) should be ok. are equivalent. The docs uses // syntax because it is the