pub fn create_pattern(pattern: HtmlPattern<'_>) -> String
Expand description
Creates regular expressions for HTML elements recursively.
This methods takes an HTML element which could have nested elements and outputs a regular expression that captures the innerHTML. If the element has nested elements, it will caputure the deepest child element’s innerHTML.
§Examples
use easy_regex::helpers::html_pattern::{HtmlPattern, create_pattern};
let pattern_str = HtmlPattern {
tag_name: "div",
essential_attribute: Some("id=\"86\""),
child_html: Box::new(Some(HtmlPattern {
tag_name: "div",
essential_attribute: Some("class=\"some-class\""),
child_html: Box::new(None),
})
)};
let result = create_pattern(pattern_str);
assert_eq!(
"<div[^<>]*id=\"86\"[^<>]*>.*<div[^<>]*class=\"some-class\"[^<>]*>(.*)</div>.*</div>",
result
);