use lazy_static::lazy_static;
use regex::Regex;
lazy_static! {
static ref REGEX_NUMBER_SPACE: Regex = Regex::new(r#"[0-9] "#).unwrap();
}
pub fn find_pos_start_data_after_delimiter(
md_text_content: &str,
pos: usize,
delimiter: &str,
) -> Option<usize> {
if let Some(pos_start_data) = find_from(md_text_content, pos, delimiter) {
let pos_start_data = pos_start_data + delimiter.len();
return Some(pos_start_data);
}
None
}
pub fn find_pos_end_data_before_delimiter(
md_text_content: &str,
pos: usize,
delimiter: &str,
) -> Option<usize> {
if let Some(pos_end_data) = find_from(md_text_content, pos, delimiter) {
return Some(pos_end_data);
}
None
}
#[allow(clippy::integer_arithmetic)]
pub fn find_from(text: &str, from_pos: usize, find: &str) -> Option<usize> {
let slice01 = text.get(from_pos..).unwrap();
let option_location = slice01.find(find);
if let Some(location) = option_location {
Some(from_pos + location)
} else {
option_location
}
}