MCPcopy Index your code
hub / github.com/RustPython/RustPython / sub

Function sub

crates/stdlib/src/re.rs:122–134  ·  view source on GitHub ↗
(
        pattern: PyStrRef,
        repl: PyStrRef,
        string: PyStrRef,
        count: OptionalArg<usize>,
        flags: OptionalArg<usize>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

120
121 #[pyfunction]
122 fn sub(
123 pattern: PyStrRef,
124 repl: PyStrRef,
125 string: PyStrRef,
126 count: OptionalArg<usize>,
127 flags: OptionalArg<usize>,
128 vm: &VirtualMachine,
129 ) -> PyResult<String> {
130 let flags = extract_flags(flags);
131 let regex = make_regex(vm, pattern.as_str(), flags)?;
132 let limit = count.unwrap_or(0);
133 Ok(do_sub(&regex, repl, string, limit))
134 }
135
136 #[pyfunction]
137 fn findall(

Callers

nothing calls this directly

Calls 4

extract_flagsFunction · 0.85
make_regexFunction · 0.85
do_subFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected