Examples with Character classes
<?php
$stringA = "1 In the beginning God created the heavens and the earth.";
$stringB = preg_replace('/[[:^alnum:]]/', '', $stringA); $stringC = preg_replace('/[[:^alpha:]]/', '', $stringA); $stringD = preg_replace('/[[:^ascii:]]/', '', "Pokémon"); $stringE = preg_replace('/[[:^blank:]]/', '*', $stringA); $stringF = preg_replace('/[[:blank:]]/', '-', $stringA); $stringG = sprintf("Vertical Tabulation: %s", chr(11)); $stringH = preg_replace('/[[:cntrl:]]/', '', $stringG); $stringLengthG = strlen($stringG); $stringLengthH = strlen($stringH); $stringI = preg_replace('/[[:digit:]]/', '', 'My age is 35'); $stringJ = preg_replace('/[[:^digit:]]/', '', 'My age is 35'); $stringK = preg_replace('/[[:^graph:]]/', '', $stringG); $stringL = preg_replace('/[[:graph:]]/', '', $stringG); $stringM = preg_replace('/[[:lower:]]/', '', $stringG); $stringN = preg_replace('/[[:^lower:]]/', '', $stringG); $stringO = preg_replace('/[[:^print:]]/', '', $stringG); $stringP = preg_replace('/[[:print:]]/', '', $stringG); $stringQ = preg_replace('/[[:punct:]]/', '', $stringG); $stringR = preg_replace('/[[:^punct:]]/', '', $stringG); $stringS = preg_replace('/[[:space:]]/', '', $stringG); $stringT = preg_replace('/[[:^space:]]/', '', $stringG); $stringU = preg_replace('/[[:upper:]]/', '', $stringG); $stringV = preg_replace('/[[:^upper:]]/', '', $stringG); $stringW = preg_replace('/[[:word:]]/', '', $stringG); $stringX = preg_replace('/[[:^word:]]/', '', $stringG); $stringY = preg_replace('/[[:xdigit:]]/', '', 'abcdefghijklmnopqrstuvwxyz0123456789'); $stringZ = preg_replace('/[[:^xdigit:]]/', '', 'abcdefghijklmnopqrstuvwxyz0123456789');