Skip to main content

regexp_replace

Function regexp_replace 

Source
pub fn regexp_replace<'a, V, E, P, R>(
    expr: E,
    pattern: P,
    replacement: R,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, E::Nullable, <<E::Aggregate as AggOr<P::Aggregate>>::Output as AggOr<R::Aggregate>>::Output>
Expand description

REGEXP_REPLACE - replaces substrings matching a POSIX regex (PostgreSQL).

Replaces the first match of pattern in expr with replacement. Use optional flags (e.g., "g" for global) via regexp_replace_flags.

ยงExample

use drizzle_core::expr::regexp_replace;

// SELECT REGEXP_REPLACE(users.phone, '[^0-9]', '')
let digits_only = regexp_replace(users.phone, "[^0-9]", "");