uf_replace_all()

Share this topic:



Link to this posting

Postby Ursego » 19 Apr 2013, 10:44

Replaces all occurrences of a fragment in a string with another fragment.

Code: Select all
/**********************************************************************************************************************
Acc:   public
-----------------------------------------------------------------------------------------------------------------------
Dscr:   Replaces all occurrences of a fragment in a string with another fragment.
-----------------------------------------------------------------------------------------------------------------------
Arg:   rs_processed_string (ref) - the string in which replacement should take place.
      as_old_frag - the fragment to be replaced.
      as_new_frag - the fragment to replace with.
**********************************************************************************************************************/
long   ll_pos
long   ll_old_frag_len
long  ll_new_frag_len

ll_old_frag_len = Len(as_old_frag)
ll_new_frag_len = Len(as_new_frag)

ll_pos = Pos(rs_processed_string, as_old_frag)
do while ll_pos > 0
   rs_processed_string = Replace(rs_processed_string, ll_pos, ll_old_frag_len, as_new_frag)
   ll_pos = Pos(rs_processed_string, as_old_frag, ll_pos + ll_new_frag_len)
loop

return
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 0 guests


uf_replace_all()

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





cron
free counters

eXTReMe Tracker