* Thus wrote Reuben D. Budiardja ([EMAIL PROTECTED]):
> 
> Hi all,
> My guess is I miss something really dumb, but here is my problem. I want to 
> use ereg to find some pattern, but it doesn't seems to work. The same pattern 
> uses with ereg_replace, works fine and replaced the pattern. Here is my code, 
> and the output:
> 
> <?
> $string = "This is a %ANS[1] test, and %ANS[2] test, and %ANS[10], test";
> echo "String is: $string\n";
> 
> $pattern = "%ANS[[0-9]+]";

Should be:
'%ANS\[[0-9]+\]'

note also the single quote to avoid needing to avoid escaping the escape:

what you have i think  would match:
%ANS9
or 
%ANS+

I'm not sure how the nested character classes work with ereg.

Also I would look at the PCRE functions, they are in general faster
than the standard ereg* functions.  Unless you require a POSIX
compatible script. 

HTH,

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

Reply via email to