Checking a value in its available in a string

Please add the Phoenix tag (as well as two other tags) when posting threads in this section. Thanks!

how can i check if 203 is avaliable in this string [“101,201,106,102,202,203”]

String.contains? (String — Elixir v1.20.2) if you don’t care about the comma separation. If you do want to split on commas first, you could do something like..

 list_of_strings = String.split(input, ",")
 Enum.any?(list_of_strings, fn x -> x == "203" end)

Edit: Which I would probably code as
Edit2: Fixed typo

 input |> String.split(",") |> Enum.any?(&(&1=="203"))

this solution works.. i tested it and it worked.. thank you very much