History of Idiom 63 > diff from v17 to v18
Edit summary for version 18 by :
↷
Version 17
2015-09-05, 10:30:11
Version 18
2015-10-29, 14:05:15
Idiom #63 Replace fragment of a string
Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.
Idiom #63 Replace fragment of a string
Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20let%20x%20%3D%20%22lorem%20ipsum%20dolor%20lorem%20ipsum%22%3B%0A%20%20%20%20let%20y%20%3D%20%22lorem%22%3B%0A%20%20%20%20let%20z%20%3D%20%22LOREM%22%3B%0A%0A%20%20%20%20let%20x2%20%3D%20x.replace(%26y%2C%20%26z)%3B%0A%20%20%20%20%0A%20%20%20%20println!(%22%7B%7D%22%2C%20x2)%3B%0A%7D%0A&version=stable
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20let%20x%20%3D%20%22lorem%20ipsum%20dolor%20lorem%20ipsum%22%3B%0A%20%20%20%20let%20y%20%3D%20%22lorem%22%3B%0A%20%20%20%20let%20z%20%3D%20%22LOREM%22%3B%0A%0A%20%20%20%20let%20x2%20%3D%20x.replace(%26y%2C%20%26z)%3B%0A%20%20%20%20%0A%20%20%20%20println!(%22%7B%7D%22%2C%20x2)%3B%0A%7D%0A&version=stable
Comments bubble
auto x2 = replace(x,y,z)
but easier to guess operation in this form
Comments bubble
auto x2 = replace(x,y,z)
but easier to guess operation in this form