Str*_*s3D 0 testing erlang substring elixir bitstring
我如何在Elixir中查找子字符串是否与另一个位串一起出现?我需要验证位串X是否存在于位串Y中的某个位置以进行测试.使用现有功能有一种简单的方法吗?
x = "bar"
y = "foo bar baz"
some_substring_function(x, y)
Run Code Online (Sandbox Code Playgroud)
与some_substring_function返回truthy值.
提前致谢!
您可以使用=~运营商:
iex> "hello world" =~ "hello"
true
Run Code Online (Sandbox Code Playgroud)
该字符串模块也有一些便利的功能.
| 归档时间: |
|
| 查看次数: |
227 次 |
| 最近记录: |