Write instead:
select * from table where name ~ 'foo'
The '~' operator produces a boolean result for whether the regex matches or not rather than extracting the matching subgroups.