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 1 year has passed since last update.

文字列の分割を最初に出てきた分割文字のみで分割

Posted at

_で分割したいけどスプリットで分割すると後の-まで分割されちゃうよ。。って人のために

Function SplitFirstUnderscore(ByVal text As String) As Variant
    Dim splitPos As Integer
    splitPos = InStr(text, "_")  ' 最初のアンダースコアの位置を見つける

    If splitPos > 0 Then
        ' アンダースコアが見つかった場合、文字列を分割する
        SplitFirstUnderscore = Array(Left(text, splitPos - 1), Mid(text, splitPos + 1))
    Else
        ' アンダースコアがない場合、元の文字列をそのまま返す
        SplitFirstUnderscore = Array(text, "")
    End If
End Function
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?