Postgres regex matching with squiggles
Postgres supports POSIX regex pattern matching using the squiggle (~
) operator
-- Check for a match
select 'wibble' ~ 'ubb';
-- returns false
select 'wibble' ~ 'ibb';
-- returns true
-- Case insensitive match checking
select 'wibble' ~ 'IBB';
-- returns false
select 'wibble' ~* 'IBB';
-- returns true
-- Check for no match
select 'wibble' !~ 'ibb';
-- returns false
select 'wibble' !~ 'ubb';
-- returns true
Full postgres pattern matching documentation can be found here
Tweet