Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use regex::Regex;
- fn strip_comments(string: &str) -> String {
- // Remove line comments
- let line_comments = Regex::new(r"//.*(\r\n|\n|\r)").unwrap();
- line_comments.replace_all(string, "$1").into_owned()
- }
- fn main() {
- let a = "// comment\r should not be a comment\n";
- println!("{}", strip_comments(a));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement