Re: find_replace() not working
- Posted by DerekParnell (admin) Sep 10, 2010
- 1216 views
useless said...
include std/search.e -- find_replace() sequence badbadchars = {"/"} sequence title = "SCRs, SCR/Diode - Arrays" sequence filteredtitle, junk with trace trace(1) filteredtitle = title for badloop = 1 to length(badbadchars) do junk = badbadchars[badloop] filteredtitle = find_replace(badbadchars[badloop],filteredtitle,"-",0) end for puts(1,filteredtitle&"\n") trace(1)
The badbadchar in filteredtitle is never replaced. Why?
also doesn't work if i use:
filteredtitle = find_replace({badbadchars[badloop]},filteredtitle,"-",0)
useless
Its not working how you expected it to because you are trying to find the STRING "/" inside filteredtitle but that variable doesn't contain that string. It does however contain the character '/'.
Try this ...
include std/search.e -- find_replace() sequence badbadchars = "/" sequence title = "SCRs, SCR/Diode - Arrays" sequence filteredtitle filteredtitle = title for badloop = 1 to length(badbadchars) do filteredtitle = find_replace(badbadchars[badloop],filteredtitle,'-',0) end for puts(1,filteredtitle&"\n")