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

Function groups

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

Source from the content-addressed store, hash-verified

124 /* groups: capture groups of the first match, or None. */
125 #[plugin_fn]
126 fn groups(pattern: String, string: String) -> Result<Option<Handle>> {
127 let Some(f) = rx(main::find(&pattern, &string, Mode::Search))? else { return Ok(None); };
128 let list = Handle::new_list()?;
129 for g in &f.groups {
130 let h = match g {
131 Some(s) => encode(Value::Bytes(s.clone().into_bytes()))?,
132 None => encode(Value::None)?,
133 };
134 list.call("append", &[h.raw()])?;
135 }
136 Ok(Some(list))
137 }
138
139 /* span: codepoint start and end of the first match as a two element list. */
140 #[plugin_fn]

Callers

nothing calls this directly

Calls 6

rxFunction · 0.85
BytesClass · 0.85
findFunction · 0.50
encodeFunction · 0.50
callMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected