1. Replacing
- Posted by irv Dec 19, 2010
- 1257 views
What library routine do I use to change:
/home/irv/storm%20clouds.jpg -- to /home/irv/storm clouds.jpg
I tried find_replace("%20",fname," "), which doesn't change the filename at all.
2. Re: Replacing
- Posted by jimcbrown (admin) Dec 19, 2010
- 1222 views
What library routine do I use to change:
/home/irv/storm%20clouds.jpg -- to /home/irv/storm clouds.jpg
I tried find_replace("%20",fname," "), which doesn't change the filename at all.
match_replace("%20",fname," ")
3. Re: Replacing
- Posted by irv Dec 19, 2010
- 1208 views
Thanks! I was using replace_all, and see that it got deprecated. match_replace works.
4. Re: Replacing
- Posted by jeremy (admin) Dec 19, 2010
- 1213 views
I tried find_replace("%20",fname," "), which doesn't change the filename at all.
match_replace("%20",fname," ")
find_replace, match_replace work just like find and match. Thus
find_replace("%20", "John Doe", "Jim Doe")
is actually looking for {{'%','2','0'}} inside of {'J','o','h','n',...}
Also, these methods do not replace inplace. You must accept the result:
filename = match_replace("%20", filename, " ")
You could use find_replace in a synario such as:
find_replace("Jim", { "John", "Jack", "Joe", "Jim", "Jane" }, "Jeremy")
Jeremy
5. Re: Replacing
- Posted by jimcbrown (admin) Dec 19, 2010
- 1195 views
Thanks! I was using replace_all, and see that it got deprecated. match_replace works.
replace_all() was deprecated in favor of match_replace(). Ironic?
6. Re: Replacing
- Posted by jeremy (admin) Dec 19, 2010
- 1290 views
replace_all() was deprecated in favor of match_replace(). Ironic?
match_replace does everything replace_all did, but a bit more.
man:std_search#match_replace, i.e. replaces all by default, but you can use it to replace up to X matches. It also fits our naming scheme. find, match, find_replace, match_replace, ...
Jeremy
7. Re: Replacing
- Posted by ne1uno Dec 19, 2010
- 1267 views
What library routine do I use to change:
/home/irv/storm%20clouds.jpg -- to /home/irv/storm clouds.jpg
I tried find_replace("%20",fname," "), which doesn't change the filename at all.
there is also include std/net/url.e
encode/decode for this type of conversion.