ExpressionEngine comes with a full-featured and very fast abstracted database driver that supports both traditional structures and Active Record patterns. The database functions offer clear, simple syntax.
Use ee()->db->word_boundary_regex() when building a database REGEXP query that should match a term as a whole word:
$term = ee()->db->word_boundary_regex('cat');
$sql = 'field_id_1 REGEXP "' . ee()->db->escape_str($term) . '"';
This helper returns a pattern that is compatible with the active database. MySQL 8.0.4 and newer use ICU regular expressions and require different word-boundary handling than older MySQL versions and MariaDB, which use the legacy Spencer regular-expression markers.