f0o
-&燃气轮机;
[fF]0[oO]
,然后将其传递给
Path.wildcard/1
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
在OTP源代码中运行它会生成所有文件,其名称在任何情况下都包含“reAdmE”。
"**/*[rR][eE][aA][dD][mM][eE].*"
["README.md", "erts/emulator/pcre/README.pcre_update.md",
"lib/erl_interface/src/README.internal",
"lib/ic/examples/pre_post_condition/ReadMe.txt", "xcomp/README.md"]
我已经用
find
:
$ find . -iname 'readme.*'
./erts/emulator/pcre/README.pcre_update.md
./lib/erl_interface/src/README.internal
./lib/ic/examples/pre_post_condition/ReadMe.txt
./README.md
./xcomp/README.md