以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于获取某段字符 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69908) |
-- 作者:sara -- 发布时间:2015/6/12 16:04:00 -- 关于获取某段字符 我想获取从右边开始第二个逗号右边的字符 |
-- 作者:sloyy -- 发布时间:2015/6/12 16:34:00 -- 分2步 1 获取右边开始第二个逗号的字符位置 LastIndexOf(",",LastIndexOf(",",0)) 2 取从字符位置开始到结束的字符 SubString(LastIndexOf(",",LastIndexOf(",",0))+1)
|
-- 作者:大红袍 -- 发布时间:2015/6/12 16:55:00 -- Dim str As String = "1234,56,789,10,111234" Dim ary() As String = str.Split(",") If ary.Length >= 2 Then str = ary(ary.Length-2) & "," & ary(ary.Length-1) End If msgbox(str) |
-- 作者:lsy -- 发布时间:2015/6/12 16:59:00 -- Dim s As String = "asdf,ois,efFox2343,98jSDF34,Fox900" Dim cnt As Integer = s.Split(",").Length - 2 \'第几个逗号(","),本例是倒数第2个 Output.Show(s.SubString(Functions.Execute("字符串位置",s,",",cnt) + 1))
|