Skip to content

Instantly share code, notes, and snippets.

@janmarsicek
Last active June 22, 2018 10:15
Show Gist options
  • Save janmarsicek/dcfea8a192aa8be913359af81fd4e569 to your computer and use it in GitHub Desktop.
Save janmarsicek/dcfea8a192aa8be913359af81fd4e569 to your computer and use it in GitHub Desktop.
let getListFromSearch = search =>
search
|> Js.String.split("&")
|> Array.to_list;
let parseUrlSearch = (stringToBeFound, search) =>
switch (search |> getListFromSearch |> List.find(stringToBeFound |> Js.String.startsWith)) {
| item => item |> Js.String.replace(stringToBeFound, "")
| exception Not_found => ""
};
let emailString = "email=";
Js.log("foo&[email protected]&displayModal=1" |> parseUrlSearch(emailString));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment