标签:
//====================================================================
// 事件: w_main.of_replace()
//--------------------------------------------------------------------
// 描述:示例:of_replace("12-3--456-78-9",‘-‘,‘=‘,2)
//--------------------------------------------------------------------
// 参数:
// value string as_string 原字符串
// value string as_old 被替换的字符串;可以是多个字符,可以是中文
// value string as_new
// value long al_count 替换的次数,小于等于0不限制;
//--------------------------------------------------------------------
// 返回: string
//--------------------------------------------------------------------
// 作者: qxx 日期: 2015年11月24日
//--------------------------------------------------------------------
// 调用位置:
//--------------------------------------------------------------------
// 修改历史:
// -------------------
//注意:as_string的长度可能会出问题:
// string: Any ASCII character with variable length (0 to 2,147,483,647).
//====================================================================
string ls_string,ls_old,ls_new,ls_return
long ll_count,ll_pos,ll_start,ll_len,ll_count_rep
ls_string = as_string
ls_new = as_new
ls_old = as_old
ll_count = al_count
ll_len = len(ls_old)
ls_return = ""
ll_pos = 0
if isnull(ls_string) or ls_string = ‘‘ then
return ""
end if
do while true
ll_pos = pos(ls_string,ls_old,1)
if ll_pos > 0 then
if ll_count > 0 then ll_count_rep += 1
ls_return += mid(ls_string,1,ll_pos - 1)+ls_new
ls_string = mid(ls_string,ll_pos+ll_len)
else
ls_return += ls_string
exit
end if
if ll_count_rep>=ll_count and ll_count > 0 then
ls_return += ls_string
exit
end if
loop
return ls_return
标签:
原文地址:http://www.cnblogs.com/QIAOXINGXING001/p/5023101.html