Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # <> operator allows the input parameters to be pattern matched
  2.  
  3. # input = "# This will be an h1"
  4. # h = "#"
  5. # t = "This will be an h1"
  6. defp parse_header_tag(input = "#" <> _) do
  7. [h|t] = String.split(input)
  8. construct_header(String.length(h), Enum.join(t, " "))
  9. end
  10.  
  11. # input = "__This will be bold__"
  12. defp parse_header_tag(input) do
  13.  
  14. end
  15.  
  16. # String.replace
  17. "__This will be bold__" |> String.replace(~r/__([^_]+)__/, "") -> ""
  18. "__This will be bold__" |> String.replace(~r/__([^_]+)__/, "<strong>\\1</strong>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement