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.

Groovy でドットを区切り文字として使用して文字列を分割する

Posted at

久々の投稿。
ぐぐってもいまいちヒットせず、Groovyでドットを区切り文字として使用して文字列を分割する方法がわからず、ちょっとハマったので覚書を残しておく。

こんな感じで記述してみたら・・・

def str = "str.split"
def dst = str.split(".")
println("dst[1] = "+dst[1]

失敗

Caught: java.lang.ArrayIndexOutOfBoundsException: 1

で、このように書いた。

def str = "str.split"
def dst = str.split("\\.")
println("dst[1] = "+dst[1]

実行結果

dst[1] = split

区切り文字は \\. って書かないとダメなのね・・・

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?