0
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 3 years have passed since last update.

[Julia occursin] Stringの中に目的のStringが存在するかチェック

Posted at

Stringの中に目的のStringが存在するかチェック

Juliaだと

occursin("ab", "abc")  # Stringがあるかをチェック
# true

occursin("12", "abc")
# false

'a' in "abc"  # Charがあるかをチェック
# true

'1' in "abc"
# false

occursinfindfirstfindnext とほぼ同じ。詳しくは以下を参照。
https://github.com/JuliaLang/julia/blob/539f3ce943f59dec8aff3f2238b083f1b27f41e5/base/strings/search.jl

# 以下の二つは同じ
occursin("ab", "abc")
findfirst("ab", "abc") != nothing

Pythonだと

"ab" in "abc"  #  Stringがあるかをチェック
# True

"12" in "abc"  
# False

'a' in "abc"  # Charがあるかをチェック
# True

'1' in "abc"
# False

Version

julia version 1.0.5

0
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
0
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?