Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Last active August 29, 2015 14:06
Show Gist options
  • Save j-mcnally/fb67238b410b92d36cb1 to your computer and use it in GitHub Desktop.
Save j-mcnally/fb67238b410b92d36cb1 to your computer and use it in GitHub Desktop.
defp extract_links(link_string) do
if link_string do
parts = for link <- String.split(link_string, ", "), do: Regex.named_captures(~r/\<.*\?page=(?<page>.*)\>; rel=\"(?<position>.*)\"/, link, capture: :all_but_first)
for capture <- parts, into: %{}, do: {Map.get(capture, "position"), Map.get(capture, "page")}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment