weixin_40187983
2018-07-17 05:43
采纳率: 73.6%
浏览 500
已采纳

简单的字串切割vb.net

原始字串aaaa,bbb,ddd,eee,sss,ffdsa

---------------切成以下两个字串-------------------

dim 字串1 as string=aaaa

dim 字串2 as string= or 0=bbb,|or 0=ddd,|or 0=eee,|or 0=sss,|or 0=ffdsa

字串1,就只有开头最前面的
字串2 串起来就比较特殊,用到 ,|or 0= 去做间隔

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • blownewbee 2018-07-17 07:52
    已采纳

    dim arr = split("aaaa,bbb,ddd,eee,sss,ffdsa", ",")
    dim 字串1 as string= arr(0)

    dim 字串2 as string= string.Join(",", arr.Skip(1).Select(Function(x) "|or 0=" + x).ToArray())

    点赞 打赏 评论
  • weixin_39743308 2018-07-17 06:45

    字串1 =mid(原始字串,1,4)
    字串2=原始字串.replace(",",",|or 0 =")

    点赞 打赏 评论
  • yuanqisihai 2018-07-17 06:57

    Dim a() As String = System.Text.RegularExpressions.Regex.Split(TextBox1.Text, ",")
    Dim 字符串1 As String = a(0)
    Dim 字符串2 As String = "or 0="
    For i = 1 To UBound(a)
    If (i = 1) Then
    字符串2 += a(i)
    else
    字符串2 += ",|or 0= " & a(i)
    End If
    Next

    点赞 打赏 评论

相关推荐 更多相似问题