Expand description
preg_replace($pattern, $replacement, $subject) support - the target
of larust-convert’s Blade expression translator (larust_convert:: blade::expr::translate’s "preg_replace" arm). That translator only
ever emits a call here after already compiling the same pattern
literal with this exact regex crate at convert time (its own
self-check, mirroring syn::parse_str::<syn::Expr>’s role everywhere
else in that translator) - so replace_all’s pattern argument is
never expected to fail to compile for converter-generated call sites.
It still doesn’t panic on one that does (a hand-written call, or a
pattern edited after conversion): falling back to returning subject
unchanged is the same “never fail, best-effort” choice
larust_support::date::strtotime already makes, for the same reason -
this is a runtime helper, not the converter’s own convert-time
rejection path.
Functions§
- replace_
all - Replaces every match of
pattern(a Rustregex-syntax pattern -larust-convertis responsible for translating PHP’s PCRE delimiter/ flag syntax into this form before ever generating a call here) insubjectwithreplacement, which may use$1-style backreferences exactly like PHP’s ownpreg_replacereplacement string.replacement/subjectaccept bothStringand&strso the converter’s own translated sub-expressions (a string literal, or aformat!(...)-producedStringfrom a.-concatenation) both work as call-site arguments without the converter needing to know which shape it produced.