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 144 views
1 answer 137 views
1 answer 153 views
2 answers 182 views
1 answer 142 views
1 answer 140 views
1 answer 2,242 views
...