1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

概要

paiza.ioでelixirやってみた。
String使ってみた。

サンプルコード

String.at("elixir", 1)
|> IO.puts
String.bag_distance("abcd", "abc")
|> IO.puts
String.capitalize("fin")
|> IO.puts
String.chunk(<<?a, ?b, ?c, 0>>, :valid)
|> IO.puts
String.codepoints("\u003c")
|> IO.puts
String.contains?("elixir of life", "of")
|> IO.puts
String.downcase("ABCD")
|> IO.puts
String.duplicate("abc", 2)
|> IO.puts
String.ends_with?("language", "age")
|> IO.puts
String.equivalent?("abc", "abc")
|> IO.puts
String.first("elixir")
|> IO.puts
String.graphemes("\u003e")
|> IO.puts
String.jaro_distance("Dwayne", "Duane")
|> IO.puts
String.last("elixir")
|> IO.puts
String.length("elixir")
|> IO.puts
String.match?("foo", ~r/foo/)
|> IO.puts
string1 = "fox hops over the dog"
string2 = "fox jumps over the lazy cat"
String.myers_difference(string1, string2)
|> IO.inspect
String.next_codepoint("olá")
|> IO.inspect
String.next_grapheme("olá")
|> IO.inspect
String.next_grapheme_size("olá")
|> IO.inspect
String.normalize("fi", :nfkc)
|> IO.puts
String.pad_leading("abc", 5)
|> IO.puts
String.pad_trailing("abc", 5)
|> IO.puts
String.printable?("abc")
|> IO.puts
String.replace("a,b,c", ",", "-")
|> IO.puts
String.replace_leading("hello world", "hello ", "hi ")
|> IO.puts
String.replace_prefix("world", "hello ", "")
|> IO.puts
String.replace_suffix("hello", " world", "")
|> IO.puts
String.replace_trailing("hello world", " world", "")
|> IO.puts
String.reverse("abcd")
|> IO.puts
String.slice("elixir", 1..3)
|> IO.puts
String.slice("elixir", 1, 3)
|> IO.puts
String.split("foo bar")
|> IO.inspect
String.split("a,b,c", ",")
|> IO.inspect
String.split_at("sweetelixir", 5)
|> IO.inspect
String.splitter("1,2 3,4 5,6 7,8,...,99999", [" ", ","]) 
|> Enum.take(4)
|> IO.inspect
String.starts_with?("elixir", "eli")
|> IO.puts
String.to_atom("my_atom")
|> IO.puts
String.to_charlist("æß")
|> IO.puts
_ = :my_atom
String.to_existing_atom("my_atom")
|> IO.puts
String.to_float("2.2017764e+0")
|> IO.puts
String.to_integer("123")
|> IO.puts
String.to_integer("3FF", 16)
|> IO.puts
String.trim("\n abc\n  ")
|> IO.puts
String.trim("a  abc  a", "a")
|> IO.puts
String.trim_leading("\n  abc   ")
|> IO.puts
String.trim_leading("__ abc _", "_")
|> IO.puts
String.trim_trailing("   abc\n  ")
|> IO.puts
String.trim_trailing("_ abc __", "_")
|> IO.puts
String.upcase("abcd")
|> IO.puts
String.valid?("a")
|> IO.puts





実行結果

l
0.75
Fin
abc
<
true
abcd
abcabc
true
true
e
>
0.8222222222222223
r
6
true
[
  eq: "fox ",
  del: "ho",
  ins: "jum",
  eq: "ps over the ",
  del: "dog",
  ins: "lazy cat"
]
{"o", "lá"}
{"o", "lá"}
{1, "lá"}
fi
  abc
abc  
true
a-b-c
hi world
world
hello
hello
dcba
lix
lix
["foo", "bar"]
["a", "b", "c"]
{"sweet", "elixir"}
["1", "2", "3", "4"]
true
my_atom
æß
my_atom
2.2017764
123
1023
abc
  abc  
abc   
 abc _
   abc
_ abc 
ABCD
true


成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?