[Proposal] Path.wildcard with [:case_insensitive] option

46 views
Skip to first unread message

Charles Okwuagwu

unread,
Aug 9, 2017, 3:36:02 PM8/9/17
to elixir-lang-core
Hi, 

I feel this could be a useful addition to the `Path.wildcard/2` function.

How to do case-insensitive search might not be immediately obvious, but it does have some value.

Would a PR for this be welcome?

defmodule A do
  def case_insensitive_glob(glob) do
    Regex.replace(~r/[a-zA-Z]/, glob, fn letter ->
      "[#{String.downcase(letter)}#{String.upcase(letter)}]"
    end)
  end
end

glob = A.case_insensitive_glob("**/*reAdmE.*") |> IO.inspect
Path.wildcard(glob) |> IO.inspect

Onorio Catenacci

unread,
Aug 21, 2017, 5:54:32 PM8/21/17
to elixir-lang-core
FWIW, this might have value on *nixes but not on Windows. Windows is case-insensitive in regards to paths.

Charles Okwuagwu

unread,
Aug 21, 2017, 5:59:41 PM8/21/17
to elixir-lang-core
Path.wildcard is case-sensitive regardless of platform.

This would be useful on any platform. 

Onorio Catenacci

unread,
Aug 21, 2017, 6:04:07 PM8/21/17
to elixir-lang-core
My mistake for making the assumption that the behavior would correspond to the behavior of the underlying OS.

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/hvm6iQBxsNU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/4d0efbca-53fd-4130-8ada-ea741388d00c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages