mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
move all regex into lazy static
This commit is contained in:
@@ -2,13 +2,16 @@ use regex::Regex;
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
const SPACES :&str= "\\s+";
|
||||
const DOTX : &str = "[^.X]";
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
static ref SPACES: Regex =Regex::new("\\s+").unwrap();
|
||||
static ref DOTX: Regex = Regex::new("[^.X]").unwrap();
|
||||
}
|
||||
|
||||
pub fn toBitArray( bits:&str) -> BitArray{
|
||||
let mut ba_in = BitArray::new();
|
||||
let replacer_regex = Regex::new(DOTX).unwrap();
|
||||
let str = replacer_regex.replace_all(bits, "");
|
||||
let str = DOTX.replace_all(bits, "");
|
||||
for a_str in str.chars() {
|
||||
// for (char aStr : str) {
|
||||
ba_in.appendBit(a_str == 'X');
|
||||
@@ -27,6 +30,5 @@ pub fn toBitArray( bits:&str) -> BitArray{
|
||||
}
|
||||
|
||||
pub fn stripSpace( s:&str) -> String{
|
||||
let replacer_regex = Regex::new(SPACES).unwrap();
|
||||
replacer_regex.replace_all(s, "").to_string()
|
||||
SPACES.replace_all(s, "").to_string()
|
||||
}
|
||||
Reference in New Issue
Block a user