惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 杨勇平

Oracle 的十八般武艺 台球常用术语解释以及英文对照 b/s开发常用javaScript技术 图片加水印 - 杨勇平 - 博客园 GridView的小技巧(1)--如何实现鼠标划过改变GridView的行背景色 HTTP状态码及其含义 ASP.NET分页组件学与用——教学篇 C#常用函数和方法集汇总 javascipt分页函数 Ajax实现无刷新三联动下拉框 慢慢的溜达 程序员贬值是个骗局! 警惕 男人难逃的五大"诱惑" 宽容 享受 人生中二十五件最重要的事情 asp.net+JSON+AJAX(基于prototype1.4)做无刷新的2级DropDownList 无题 证明题
Split函数详解 - 杨勇平 - 博客园
杨勇平 · 2006-12-09 · via 博客园 - 杨勇平

Split函数
描述
返回一个下标从零开始的一维数组,它包含指定数目的子字符串。
语法
Split(expression[, delimiter[, count[, compare]]])
Split函数语法有如下几部分:
部分 描述
expression 必需的。包含子字符串和分隔符的字符串表达式 。如果expression是一个长度为零的字符串(\"\"),Split则返回一个空数组,即没有元素和数据的数组。
delimiter 可选的。用于标识子字符串边界的字符串字符。如果忽略,则使用空格字符(\" \")作为分隔符。如果delimiter是一个长度为零的字符串,则返回的数组仅包含一个元素,即完整的 expression字符串。
count 可选的。要返回的子字符串数,–1表示返回所有的子字符串。
compare 可选的。数字值,表示判别子字符串时使用的比较方式。关于其值,请参阅“设置值”部分。

设置值
compare参数的设置值如下:
常数 值 描述
vbUseCompareOption –1 用Option Compare语句中的设置值执行比较。
vbBinaryCompare 0 执行二进制比较。
vbTextCompare 1 执行文字比较。
vbDatabaseCompare 2 仅用于Microsoft Access。基于您的数据库的信息执行比较。
split函数的使用:
      For Example:
      <%
      public namearray
      qname="Wang;Zhang;Ning"
      response.write qname & "<p><br>"
      namearray=split(qname,";") '把qname字符串以分号分开,然后赋给一个数组
      max=ubound(namearray)
      for counter=0 to max-1
      response.write namearray(counter) & "<p><br>"
      next
      response.write "<hr>"
      %>

本例是一个数据库查询的例子,通过Split函数对查询字段进行了切割。
用于想灵活控制查询或开发更深层应用的一个例子。
<%
     Dim Conn
     Dim Rs
     Dim j
     Dim i
     Set Conn = Server.CreateObject("adodb.connection")
     Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("Mydatabase\#GuestBook.mdb")
     Set Rs = Server.CreateObject("Adodb.RecordSet")
     'StrSql="Select * From GuestBook" '等同于下句。
     StrSql=SplitText("Title Content"," ","Select "," From GuestBook",",")
     Rs.Open StrSql, Conn, 1, 3
     Call RsFieldShow("Title Content"," ","标题: 内容:","<br/> <br/>")
     'j=Rs.Fields.count
     'For i=0 to (j-1)
     ' Response.Write("第" & i+1 & "个字段名:" & Rs.Fields(i).Name & "<br><br>")
     'Next
%>
<%
'ASP中把要查询的字段(Content)以字符串形式传递,附有前缀(PreText)、后缀(LastText)。
'要求前后缀产生数组后,与查询字段的数目相同。
Sub RsFieldShow(Byval Content,Byval SplitMark,Byval PreText,Byval LastText)
On Error Resume Next
EveryString=Split(Content,SplitMark)'获得字符串数组,并赋值。
EveryPreText=Split(PreText,SplitMark)
EveryLastText=Split(LastText,SplitMark)
For i=LBound(EveryString) to UBound(EveryString)
Response.Write EveryPreText(i) & Rs(EveryString(i)) & EveryLastText(i) '输出
Next
End Sub
'按照指定的格式输出字符串。
Function SplitText(Byval Content,Byval SplitMark,Byval PreText,Byval LastText,Byval SplitChar)
On Error Resume Next
Dim StrQ
StrQ=Split(Content,SplitMark) '获得字符串数组,并赋值。
For i=LBound(StrQ) to UBound(StrQ) '利用函数取得数组上限和下限。
SplitText=SplitText & StrQ(i) & SplitChar '进行组合
Next
SplitText=Left(SplitText,Len(SplitText)-1) '去掉最后一个符号。
SplitText=PreText & SplitText & LastText '加上前后缀并返回。
End Function
%>