Skip to content

Instantly share code, notes, and snippets.

@xenoterracide
Created January 19, 2010 17:02
Show Gist options
  • Save xenoterracide/281093 to your computer and use it in GitHub Desktop.
Save xenoterracide/281093 to your computer and use it in GitHub Desktop.
Find empty strings or strings containing only whitespace, for postgresql
CREATE OR REPLACE FUNCTION empty(TEXT)
RETURNS bool AS
$$ SELECT $1 ~ '^[[:space:]]*$'; $$
LANGUAGE sql
IMMUTABLE;
COMMENT ON FUNCTION empty(TEXT)
IS 'Find empty strings or strings containing only whitespace';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment