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

Function span

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

Source from the content-addressed store, hash-verified

139 /* span: codepoint start and end of the first match as a two element list. */
140 #[plugin_fn]
141 fn span(pattern: String, string: String) -> Result<Option<Handle>> {
142 let Some(f) = rx(main::find(&pattern, &string, Mode::Search))? else { return Ok(None); };
143 let list = Handle::new_list()?;
144 let a = encode(Value::Int(f.start as i128))?;
145 let b = encode(Value::Int(f.end as i128))?;
146 list.call("append", &[a.raw()])?;
147 list.call("append", &[b.raw()])?;
148 Ok(Some(list))
149 }
150
151 /* sub: replace every match, expanding backreferences in the template. */
152 #[plugin_fn]

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected