Skip to content

Instantly share code, notes, and snippets.

@le0pard
Created December 13, 2022 13:40
Show Gist options
  • Save le0pard/7ecfadacccec11a98b791f47c8a6c7a8 to your computer and use it in GitHub Desktop.
Save le0pard/7ecfadacccec11a98b791f47c8a6c7a8 to your computer and use it in GitHub Desktop.
create function lcfirst(word text)
returns text
language plpgsql
immutable
as $$
begin
return lower(left(word, 1)) || right(word, -1);
end;
$$;
create function camel_case(snake_case text)
returns text
language plpgsql
immutable
as $$
begin
return
replace(
initcap(
replace(snake_case, '_', ' ')
),
' ', ''
);
end;
$$;
select lcfirst(camel_case('snek_snek_snek'));
lcfirst
--------------
snekSnekSnek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment