Re: find_replace() not working
- Posted by useless Sep 10, 2010
- 1158 views
DerekParnell said...
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")
You did not notice the first block of eucode i did first is just what you said to try. That's what didn't work first. What didn't work second was the the second block of eucode i gave. You responded to the second block of code, telling me to try the first block, which already didn't work.
I had also tried:
sequence badbadchars = {'/'}
useless