pb的replace完善

pb的replace来用,pb的replace完善
正常来说,在一个项目里都会写个全局replace函数,如下

$PBExportHeader$gf_replace.srf
global type gf_replace from function_object
end type

forward prototypes
global function string gf_replace (ref string as_source, string as_old, string as_new)
end prototypes

global function string gf_replace (ref string as_source, string as_old, string as_new);//gf_replace
//功能:在一个字符串(ls_temp)中将一字符串(as_old)替换成另一个字符串(as_new)
//返回:被替换成功后的字符串

string ls_temp
long ll_pos=1

ls_temp = as_source
// Find the first occurrence of as_old.
ll_pos = Pos(ls_temp, as_old, ll_pos)
// Only enter the loop if you find as_old.
DO WHILE ll_pos > 0
  // Replace as_old with as_new.
  ls_temp = Replace(ls_temp, ll_pos, Lenw(as_old), as_new)
  // Find the next occurrence of as_old.
  ll_pos = Pos(ls_temp, as_old, ll_pos+Lenw(as_new))
LOOP

return ls_temp
//
end function
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值