Skip to main content

regexp_replace_flags

Function regexp_replace_flags 

Source
pub fn regexp_replace_flags<'a, V, E, P, R, F>(
    expr: E,
    pattern: P,
    replacement: R,
    flags: F,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, E::Nullable, <<<E::Aggregate as AggregateKind>::Or<P::Aggregate> as AggregateKind>::Or<R::Aggregate> as AggregateKind>::Or<F::Aggregate>, (E::Sources, (P::Sources, (R::Sources, F::Sources)))>
Expand description

Replaces POSIX regular expression matches, with flags, on PostgreSQL.

Like regexp_replace with a fourth argument: renders REGEXP_REPLACE(expr, pattern, replacement, flags).

Common flags: "g" (every match), "i" (ignore case), "gi" (both). All arguments must be text. The result is text and keeps expr’s nullability.

§Examples

let digits = regexp_replace_flags(users.name, "[^0-9]", "", "g");
assert_eq!(digits.sql(), r#"REGEXP_REPLACE ("users"."name", $1, $2, $3)"#);