uf_replace_all()


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
/**********************************************************************************************************************
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.
***********************************************************************************************************************
Developer:   Michael Zuskin - LinkedIn: http://linkedin.com/in/zuskin
**********************************************************************************************************************/
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: 143
Joined: 19 Feb 2013, 20:33



Ketones are a more high-octane fuel for your brain than glucose. Become a biohacker and upgrade yourself to version 2.0!



cron
Traffic Counter

eXTReMe Tracker