Created
October 13, 2015 04:52
-
-
Save dginev/3469d370dc211fe7be2b to your computer and use it in GitHub Desktop.
Remove NULL chars in Unicode strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate regex; | |
use regex::Regex; | |
fn main() { | |
let test = "\u{123}\u{000}\u{143}\u{00}"; | |
let no_nulls_regex = Regex::new(r"\x00").unwrap(); | |
println!("Before: {:?}", test); | |
let sanitized = no_nulls_regex.replace_all(test,""); | |
println!("Sanitized: {:?}", sanitized); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment