Function chewdata::updater::tera_helpers::function::string::find

source ·
pub fn find(args: &HashMap<String, Value>) -> Result<Value>
Expand description

Returns a list of string found. See https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter.

Arguments:

  • pattern - regex expression to identify what you want to find from a string.
  • value - Value to analyse.

§Examples

use std::collections::HashMap;
use serde_json::value::Value;
use chewdata::updater::tera_helpers::function::string::find;

let mut args = HashMap::new();
args.insert("value".to_string(), Value::String("Hello, world!".to_string()));
args.insert("pattern".to_string(), Value::String(r"\w+".to_string()));

let result = find(&args).unwrap();
assert_eq!(
    result,
    Value::Array(vec![
        Value::String("Hello".to_string()),
        Value::String("world".to_string())
    ])
);