I'm looking for a regex that i can use in my tokenizer to compile a config file. Here is a snippet out of a class in php:
private $token = array(
"PATH" => "([a-zA-Z\_-]+\.|\*\.)+([a-zA-Z\_-]+|\*)",
"MIXED" => "[a-zA-Z0-9-_\(\)\/]{2,}",
"STRING" => "[a-zA-Z-_]{2,}"
);
private function getToken($string) {
foreach($this->token as $name => $pattern) {
preg_match("/^".$pattern."/", $string, $match);
if(!empty($match))
return array($name, $match[0]);
}
return false;
}
"MIXED" should match "foo/bar" and not "foobar" and "STRING" should match "foobar" and not "foo/bar". Currently "foobar" and "foo/bar" are "MIXED".
How do i write this "AND NOT" in a single pattern down?
Thank you.