怎样提取这种格式的数据并给变量

飞扬残月 2008-03-29 01:38:07
数据格式:3-2-1
int a,b,c
怎样提取数据使
a=3
b=2
c=1
asp中使用
...全文
62 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
苍白之月 2008-03-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 toury 的回复:]
VBS:
a=split("3-2-1")(0)
b=split("3-2-1")(1)
c=split("3-2-1")(2)
[/Quote]
正解
ymle1228 2008-03-29
  • 打赏
  • 举报
回复
string[] A;

string B = "abcd@@efg@@sdff;";
string C=abcde@efgasdfl@sdlfjs;

如果要分割C很容易,只需如此即可:
A = C.Split('@');
结果:
A[0] = "abcde";
A[1] = "efgasdfl";
A[2] = "sdlfjs";

如果要分割B呢?最简单的办法就是先把@@替换为单字符串了。

A = B.Replace("@@","$").Split('$');

A[0] = "abcd";
A[1] = "efg";
A[2] = "sdff";
ymle1228 2008-03-29
  • 打赏
  • 举报
回复
MARK
toury 2008-03-29
  • 打赏
  • 举报
回复
VBS:
a=split("3-2-1")(0)
b=split("3-2-1")(1)
c=split("3-2-1")(2)
文盲老顾 2008-03-29
  • 打赏
  • 举报
回复
a = "3-2-1"

b = split(a,"-")

' ---------------------

a = "1,2-3/4_55=66"

b = ExpStr(a,"[\d]+","$$")

Function ExpStr(vStr,vReg,sStr)
Dim Re,Matchs,Item,tStr
tStr = ""
Set Re = New RegExp
Re.Pattern = vReg
Re.IgnoreCase = True
Re.Global = True
If Re.Test(vStr) Then
Set Matchs = Re.Execute(vStr)
For Each Item In Matchs
tStr = tStr & Item.Value & sStr
Next
tStr = Split(Left(tStr,Len(tStr) - Len(sStr)),sStr)
End If
Set Re = Nothing
ExpStr = tStr
End Function

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧