Cristian Lavaque wrote:
> Jonas_weber @ Gmx . Ch wrote:
>> regular expressions
>> the example below should turn any character exept "\*" (*= any char)
>> into an "x":
>>
>> $term = preg_replace('/[^(\\\)+(.){1}]/', 'x', $term);
>>
>> but i guess because of the [brackets] the "." (period) is treated as
>> character "." instead as metacharacter (that matches any char).
>
> I'm new to regex too, but if you want to match anything that's not an
> *, couldn't it be done like this?
>
> $term = preg_replace('/[^\*\s]*/', 'x', $term);
>
> I put the \s there to skip the whitespace characters too. I haven't
> tested, but I hope it helps.
>
> Cristian

doh, I now understand your question, you don't mean the asterisk literally,
but as any character that follows a backslash... sorry -_-

In a character class, you can negate that class by starting it with ^, but
how do you negate something that's not a class? in this case "\\.", cause if
it's in a charactar class, it'll match "\n" or "n\\\\\\". Is there a simple
way to negate a string with regular expression? I hope I wasn't too
confusing in my question.

Cristian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to