vb.net字符串操作
有一字符串是数字(双精度,3,4位不等)与"@","&"如:@1991@1205@844@3276@1104@747@1069@0.9@4@3@&1048&1057&10...
有一字符串是数字(双精度,3,4位不等)与"@", "&"
如:
@1991@1205@844@3276@1104@747@1069@0.9@4@3@&1048&1057&1073&
如何操作能使我获得排除"@","&"得到数组1991,1205,844........... 展开
如:
@1991@1205@844@3276@1104@747@1069@0.9@4@3@&1048&1057&1073&
如何操作能使我获得排除"@","&"得到数组1991,1205,844........... 展开
2个回答
展开全部
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim aa As String = "@1991@1205@844@3276@1104@747@1069@0.9@4@3@&1048&1057&1073&"
Dim gs(), bb As String
gs = (aa.Trim(New Char() {"@", "&"})).Split(New Char() {"@", "&"})
bb = Regex.Replace(Join(gs, ","), ",{2,}", ",")
gs = bb.Split(",")
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim aa As String = "@1991@1205@844@3276@1104@747@1069@0.9@4@3@&1048&1057&1073&"
Dim gs(), bb As String
gs = (aa.Trim(New Char() {"@", "&"})).Split(New Char() {"@", "&"})
bb = Regex.Replace(Join(gs, ","), ",{2,}", ",")
gs = bb.Split(",")
End Sub
End Class
追问
用不着这么繁琐吧.....
追答
这已经是比较简单的做法了,最主要是你的要求是什么,有些数组为空,用去掉么?不用去掉当然会更简单,只gs =aa.Split(New Char() {"@", "&"}) 就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询