Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. use regex::Regex;
  2.  
  3. fn strip_comments(string: &str) -> String {
  4. // Remove line comments
  5. let line_comments = Regex::new(r"//.*(\r\n|\n|\r)").unwrap();
  6. line_comments.replace_all(string, "$1").into_owned()
  7. }
  8.  
  9. fn main() {
  10. let a = "// comment\r should not be a comment\n";
  11. println!("{}", strip_comments(a));
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement