求一段可以将字符分割的代码
string ls_sn
ls_sn="C13 C14 C19 C32 C42 C48 C49 C68 C69 C161 C177 C187 C191 C195 C222 C230 C262 C282 C284 C292 C293 C294 C295"
求转换成
C13
C14
C19
C32
C42
C48
C49
C68
C69
C161
C177
C187
C191
C195
C222
C230
C262
C282
C284
C292
C293
C294
C295
------解决方案--------------------
string ls_string[]
long ll_pos
string ls_sn//你要分割的字符串
ll_pos = pos(ls_sn,你的分隔符)
do while ll_pos > 0
ls_string[upperbound(ls_string)] = left(ls_sn,ll_pos - 1)
ls_sn = replace(ls_sn,1,ll_pos,'')
ll_pos = pos(ls_sn,你的分隔符)
loop
------解决方案--------------------
给个一串字符串根据分隔符分割成数组的函数你,
string ls_EmptyResult[]
long ll_Len, ll_Start, ll_End, ll_Pos
integer li_Count = 0
boolean lbl_Scan
string ls_Char
string as_Source //要分割的数据
string as_delimiter //分隔符
string as_result[] //分割后返回的数组
as_Result = ls_EmptyResult
ll_Len = Len( as_Source )
if IsNull( as_Source ) or ( ll_Len = 0 ) then return 0
lbl_Scan = ( len( as_Delimiter ) = 1 and Asc( as_Delimiter ) > 32 )
ll_Start = 1
do while( ll_Start <= ll_Len )
// Search Delimiter Position
ll_End = Pos( as_Source, as_Delimiter, ll_Start )
// Continue if need to scan and delimiter was found
if ( lbl_Scan ) and ( ll_End > ll_Start ) then
// Continue if the previous char of delimiter is a 8 bit data (may be chinese)
if ( Asc( Mid( as_Source, ll_End - 1, 1 ) ) > 127 ) then
ll_End = 0
ll_Pos = ll_Start
do while ( ll_Pos <= ll_Len )
ls_Char = Mid( as_Source, ll_Pos, 1 )
if ( Asc( ls_Char ) > 127 ) then
ll_Pos += 2
elseif ( ls_Char <> as_Delimiter ) then
ll_Pos += 1
else
ll_End = ll_Pos
exit
end if
loop
end if
end if
// Point to End of String if Delimiter Not Found
if ( ll_End = 0 ) then ll_End = ll_Len + 1
// Assign to Array of String
li_Count++
as_Result[ li_Count ] = Trim( Mid( as_Source, ll_Start, ll_End - ll_Start ) )
// Next
ll_Start = ll_End + Len( as_Delimiter )
loop
return li_Count