This is the example string:
User.status <> 'actived'
I want this:
`User`.`status` <> 'actived'
But with the following regex:
/([a-z_]+[a-z0-9_]+)/i
The result is:
`User`.`status` <> '`actived`'
A context code usage:
protected function escapeExpression($expression)
{
//$expression = "User.status <> 'actived'";
//escapeKeyword returns '`' . $param . '`'
return preg_replace('/([a-z_]+[a-z0-9_]+)/i', $this->escapeKeyword('$1'), $expression);
}
/(?<!['a-z0-9_])([a-z_]+[a-z0-9_]+)(?!['a-z0-9_])/iwould do the trick, using a negative lookbehind and a negative lookahead.