Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Jerry Fleming
May 10, 2006, 3:09 am
rate this thread
Re: regexp: match negation
Very difficult with preg_replace. If you know _exactly_ what is allowed, why
not preg_match() the string and continue working with the output from that
function? Negating characters, getting parts NOT followed or predeeded by a
specific string can be done, but negating whole words is as far as I know
Allowed are 'cat' & 'dog' & whitespacecharacters.
$tring = "dog dogcat\ncowcat";
preg_match_all('/(cat|dog|\s)/si', $tring, $matches, PREG_PATTERN_ORDER);
$allowedstring = implode($matches);