怎樣以逗號為分隔符將字串拆分
請大家指教
NA,10,31,11,10,10,FEALSOL ,HRB400V , ,HRB400V ,A,,1,,,,,,,,29,C, 0.07,Si, 0.03,Mn, 0.09,P, 0.024,S, 0.022,V, 0.000,Nb, 0.00094,Ni, 0.009,Cr, 0.009,Cu, 0.027,Alsol, 0.3581,Aloxy, 0.0607,Al, 0.41877,As, 0.00859,B, 0.00058,Bi, 0.00010,Ca, 0.00442,Co, 0.00529,Mo, 0.00086,Pb, 0.00152,Sb, 0.00056,Sn, 0.01098,Ti, 0.00088,W, 0.00010,Zn, 0.00891,Zr, 0.00058,F, 0.85517,Fe4, ,FE%, 99.2547,
uj5u.com熱心網友回復:
拆成字串陣列么?寫個函式,用回圈。。(用pos函式取,號所在位置)uj5u.com熱心網友回復:
////////////////////////////////////////////// 參 數: as_mother 字串
// as_flag 指定標志
// ai_point 第幾個指定標志
// 返 回 值: 字串
////////////////////////////////////////////
string ls_ret
long ll_start,ll_end,ll_i
ll_end = 0
if ai_point=0 then
return as_mother
end if
for ll_i = 1 to ai_point
ll_start = ll_end + 1
ll_end = posw(as_mother,as_flag,ll_start)
next
ls_ret = Mid(as_mother,ll_start,ll_end - ll_start)
return ls_ret
uj5u.com熱心網友回復:
// String Function GET_TOKEN (ref string Source, char Separator)
// The function Get_Token receive, as arguments, the string from which
// the token is to be stripped off, from the left, and the separator
// character. If the separator character does not appear in the string,
// it returns the entire string. Otherwise, it returns the token, not
// including the separator character. In either case, the source string
// is truncated on the left, by the length of the token and separator
// character, if any.
int p
string ret
p = Pos(source, separator) // Get the position of the separator
if p = 0 then // if no separator,
ret = source // return the whole source string and
source = "" // make the original source of zero length
else
ret = Mid(source, 1, p - 1) // otherwise, return just the token and
source = Right(source, Len(source) - p) // strip it & the separator
end if
return ret
呼叫方法:
do while ls_source <> ""
ls_buf = f_get_Token(ls_source, ",")
// ..
loop
uj5u.com熱心網友回復:
同意樓上的,如果有特殊需要,可以回傳陣列。更加便于操作。
uj5u.com熱心網友回復:
POS+
回圈!
uj5u.com熱心網友回復:
PFC實作最簡單,現成的n_cst_string lnv_string
string ls_value,ls_sep
ls_sep = lnv_string.of_gettoken(ls_value,',')
uj5u.com熱心網友回復:
支持用PFCuj5u.com熱心網友回復:
同意二樓方法轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/76518.html
標籤:腳本語言
