Forum Moderators: coopster

Message Too Old, No Replies

regular expressions

remove all digits and braces

         

ScottYardley

3:21 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



I'm using the php function eregi_replace and am having a bit of trouble with the regular expression.

I'm trying to remove all digits and '{}'
Here's the regular expresion portion of my code: [[:digit:],{}]
It doesn't work. It replaces digits, '{' and '}'.

I need the '{}' to be consider together not seperately.

I've also tried
[[:digit:],\{\}]

I want to use one line of code and use regular expressions for this problem.

Any help would be appreciated

StupidScript

4:51 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about using "or" operators?

[[:digit:]¦¦{¦¦}]

ScottYardley

6:09 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



No quite but you got me on the right track

this works

[[:digit:]]¦{}

I suppose this would also
0-9* ¦ {}

coopster

6:29 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, ScottYardley.

The reason it didn't work at first is because you have it in a character class. A character class matches a single character in the subject. Scan the PCRE Pattern Syntax [php.net] page for "Square Brackets" and you'll find an example.