pinchflat/lib/utils/string_utils.ex
2024-01-19 12:10:31 -08:00

14 lines
313 B
Elixir

defmodule Pinchflat.Utils.StringUtils do
@moduledoc """
Utility functions for working with strings
"""
@doc """
Converts a string to kebab-case (ie: `hello world` -> `hello-world`)
"""
def to_kebab_case(string) do
string
|> String.replace(~r/[\s_]/, "-")
|> String.downcase()
end
end