Skip to content

Instantly share code, notes, and snippets.

@dginev
Created October 13, 2015 04:52
Show Gist options
  • Save dginev/3469d370dc211fe7be2b to your computer and use it in GitHub Desktop.
Save dginev/3469d370dc211fe7be2b to your computer and use it in GitHub Desktop.
Remove NULL chars in Unicode strings
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