How to replace comma (,) with semicolon (;) in a string with Rust

1 Answer

0 votes
use std::string::String;

fn main() {
    let mut str = String::from("java,c,c++,c#,rust");

    // Replace commas with semicolons
    str = str.replace(',', ";");

    println!("{}", str);
}


   
/*
run:
  
java;c;c++;c#;rust
  
*/

 



answered Dec 3, 2024 by avibootz

Related questions

1 answer 131 views
1 answer 123 views
1 answer 142 views
2 answers 162 views
1 answer 124 views
1 answer 123 views
1 answer 2,226 views
...