标签:
//====================================================================// 事件: 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_returnlong ll_count,ll_pos,ll_start,ll_len,ll_count_repls_string = as_stringls_new = as_newls_old = as_oldll_count = al_countll_len = len(ls_old)ls_return = ""ll_pos = 0if isnull(ls_string) or ls_string = ‘‘ thenreturn ""end ifdo while truell_pos = pos(ls_string,ls_old,1)if ll_pos > 0 thenif ll_count > 0 then ll_count_rep += 1ls_return += mid(ls_string,1,ll_pos - 1)+ls_newls_string = mid(ls_string,ll_pos+ll_len)elsels_return += ls_stringexitend ifif ll_count_rep>=ll_count and ll_count > 0 thenls_return += ls_stringexitend ifloopreturn ls_return
标签:
原文地址:http://www.cnblogs.com/QIAOXINGXING001/p/5023101.html