PHP regex: what is "class at offset 0"?
php, regex
Solution
The `preg_*` functions expect Perl compatible regular expressions with delimiters. So try this:
preg_replace('/[[:punct:]]/', ' ', $string)
Problem
I'm trying to strip all punctuation out of a string using a simple regular expression and the php preg_replace function, although I get the following error: Compilation failed: POSIX named classes are supported only within a class at offset 0 I guess this means I can't use POSIX named classes outside of a class at offset 0. My question is, what does it means when it says "within a class at offset 0 "? ``` $string = "I like: perl"; if (eregi('[[:punct:]]', $string)) $new = preg_replace('[[:punct:]]', ' ', $string); echo $new; ```