bruno1: preg_replace Suchmuster

Beitrag lesen

Hi,

Sie ist gar nicht vorhanden.

Ups, da ist mir ^ wohl verrutscht...
preg_replace("/[^A-Z]/", "A", $irgendwas);
So müsste es jetzt richtig sein (alles was kein Großbuchstabe von A-Z ist wird ersetzt), aber wie ich das auf der Seite die du mir geschickt hast nachgelsen habe,

Be careful when using the negated shorthands inside square brackets. [\D\S] is not the same as [^\d\s]. The latter will match any character that is not a digit or whitespace. So it will match x, but not 8. The former, however, will match any character that is either not a digit, or is not whitespace. Because a digit is not whitespace, and whitespace is not a digit, [\D\S] will match any character, digit, whitespace or otherwise.

Das heißt [\D\S] findet alle Zeichen, aber würde [^\d\s] nicht alle Zeichen finden, die keine Zahl und kein Whitespace sind?

bruno1