|
|
|
3w....學習.教學
>
VBSCRIPT
>
array » split
|
|
|
| 3w learning
|
array > split
Title:Split(expression[,delimiter[,count[,compare]]])
可將一資料格中的長字串或數據加以分割陣列化,以方便取用 |
Description:
expression
Required. String expression containing substrings and
delimiters. If expression is a zero-length string,
Split returns an empty array, that is, an array with
no elements and no data.
delimiter
Optional. String character used to identify substring limits.
If omitted, the space character (" ") is assumed to be
the delimiter. If delimiter is a zero-length string,
a single-element array containing the entire
expression string is returned.
count
Optional. Number of substrings to be returned; -1 indicates
that all substrings are returned.
compare
Optional. Numeric value indicating the kind of comparison
to use when evaluating substrings. See Settings
section for values
vbBinaryCompare : 0 : Perform a binary comparison.
vbTextCompare : 1 : Perform a textual comparison.
----- compare setting not often use -----
often only use like this::
Split(expression[,delimiter])
最常使用的模式為 :: Split(expression[,delimiter]) |
Example Code:
Example 1 :: Split(expression[,delimiter[,count[,compare]]])
The function performs
a textual comparison of the delimiter:: [,-1]
and returns all of the substrings :: [, 1]
<% ' example code of using compare setting
Dim MyString, MyArray, Msg
MyString = "8/6/2006"
MyArray = Split(MyString, "/", -1, 1)
' MyArray(0) contains "8".
' MyArray(1) contains "6".
' MyArray(2) contains "2006".
Msg = MyArray(0) & " " & MyArray(1)
Msg = Msg & " " & MyArray(2)
MsgBox Msg
%>
Example 2 :: Split(expression[,delimiter])
from a get form
http://---.com/faq.asp?query=sports&query=baseball
<%
query=request(query")
queryList=Split(query,", ")
response.write queryList
%>
Example 3 : Split(expression)
<%
dim date,d
date="8 6 2006"
d=Split(date)
document.write(d(0) & "<br />")
document.write(d(1) & "<br />")
document.write(d(2))
%>
當只用 Split(expression) 時, 將自動以space 間隔成陣列 |
Example Result:
Example 1:
8 6 2006
Example 2:
sports, baseball
Example 3 :
8
6
2006
Tips: Split may very helpful to read a daily memo
Tips: Design a special code to divide your data so
you will be more easy to split the data.
方便日誌或雜記的資料的整理 |
|
| .. |
| ... |
| ... |
|
|
[ 11/20/2008 ]
|
|
|
| www learning school add more scripts
and tips memo |
|