Skip to content

sub

relationalai.semantics.std.re
sub(regex: StringValue, repl: StringValue, value: StringValue) -> StringValue

Replace occurrences of the regex in the value with the replacement string.

  • regex

    (StringValue) - The regular expression pattern.
  • repl

    (StringValue) - The replacement string.
  • value

    (StringValue) - The string value to perform substitution on.
  • Expression - An Expression computing the substituted string. Returns String.

Replace occurrences of a pattern in a string:

define(Text.new(content="The party starts at 8:00 PM or at 9:00 PM."))
re.sub(r"\d{1,2}:\d{2} [AP]M", "<??>", Text.content)
select(Text.content, re.sub(r"\d{1,2}:\d{2} [AP]M", "<??>", Text.content))