Re: find_replace() not working
- Posted by DerekParnell (admin) Sep 10, 2010
- 1189 views
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
I most heartily disagree with your assertion, Ms Smith.
I did notice your first example. In fact, I copied it verbatim to my own system and ran the code, and I concur that it indeed does fail. My first attempt at getting it to work was to replace the line
sequence badbadchars = {"/"}
with
sequence badbadchars = {'/'}
because I noticed that your code was using a string rather than a character, and also noticing that in the title data there was the character '/', I made the assumption that you were trying to find the character '/' in the title data.
I then reran the code and it failed at a different point. It was now saying that there was a sequence embedded in the text. At which point I slapped my forehead (metaphorically) and saw the data that your code was using to replace the '/' character with. I realized that the code was now replacing the character '/' (an atom) with the string "-" (a sequence). So I again threw caution to the wind and made another assumption ... that you were trying to replace the '/' character with the '-' character and not with the "-" string.
So I replaced the line
filteredtitle = find_replace(badbadchars[badloop],filteredtitle,"-",0)
with
filteredtitle = find_replace(badbadchars[badloop],filteredtitle,'-',0)
and now it was working. However, before posting my response to your original questions, I tempted fate by cleaning up the code by removing the tracing paraphernalia and instead of using {'/'} I simply used "/" as the list of characters to search for.
So in conclusion, I believe that I addressed all your concerns and examples accurately and furthermore, I present a working and tidier code sample.
Yours sincerely,
Derek.