MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / findall

Function findall

std/re/src/lib.rs:109–122  ·  view source on GitHub ↗
(pattern: String, string: String)

Source from the content-addressed store, hash-verified

107 /* findall: list of matches, group shaped like CPython for zero or one group. */
108 #[plugin_fn]
109 fn findall(pattern: String, string: String) -> Result<Handle> {
110 let (founds, ngroups) = rx(main::find_all(&pattern, &string))?;
111 if ngroups <= 1 {
112 let items: Vec<String> = founds.iter().map(|f| pick(f, ngroups)).collect();
113 return str_list(&items);
114 }
115 let list = Handle::new_list()?;
116 for f in &founds {
117 let groups: Vec<String> = f.groups.iter().map(|g| g.clone().unwrap_or_default()).collect();
118 let sub = str_list(&groups)?;
119 list.call("append", &[sub.raw()])?;
120 }
121 Ok(list)
122 }
123
124 /* groups: capture groups of the first match, or None. */
125 #[plugin_fn]

Callers

nothing calls this directly

Calls 8

rxFunction · 0.85
find_allFunction · 0.85
str_listFunction · 0.85
collectMethod · 0.80
pickFunction · 0.70
iterMethod · 0.45
callMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected