PB split 字符串拆分函數

$PBExportHeader$split.srf
$PBExportComments$字符串拆分函數
global type split from function_object
end type

forward prototypes
global function integer split (string assource, string astag, ref string aaret[])
end prototypes

global function integer split (string assource, string astag, ref string aaret[]);//
//  功能:拆分字符串
//  入參:asSource 源串
//       asTag    分隔符
//       aaRet[]  結果列表
//

Long i = 0, llPos, llBegin = 1

If IsNull(asSource) Then 
	Return 0
End If

llPos = Pos(asSource, asTag, llBegin)
Do While llPos > 0
	i ++
	aaRet[i] = Mid(asSource, llBegin, llPos - llBegin)
	llBegin = llPos + Len(asTag)
	llPos = Pos(asSource, asTag, llBegin)
Loop

If llBegin <= Len(asSource) Or i > 0 Then
	i ++
	aaRet[i] = Mid(asSource, llBegin, Len(asSource) - llBegin + 1)
End If

Return i
 
end function

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章