Removes top-level fields from a record when their names match a regular expression.
drop_matching(x:record, regex:string) -> recordDescription
Section titled “Description”The drop_matching function returns a record with every top-level field from
x whose field name does not match regex.
Matching is partial by default. Use ^ and $ anchors to match whole field
names or prefixes. The function does not recurse into nested records; call it
on the nested record if you want to drop fields there.
The supported regular expression syntax is RE2.
x: record
Section titled “x: record”The record whose fields you want to filter.
regex: string
Section titled “regex: string”The regular expression to match against field names.
Examples
Section titled “Examples”Remove fields by name
Section titled “Remove fields by name”from { name: "Alice", email: "alice@example.com", password: "secret", api_key: "xyz123",}select public = this.drop_matching("^(password|api_key)$"){ public: { name: "Alice", email: "alice@example.com", },}Separate matching fields from the rest
Section titled “Separate matching fields from the rest”from { foo: 1, bar: 2, baz: 3,}let $pattern = "^ba"select moved = this.select_matching($pattern), rest = this.drop_matching($pattern){ moved: { bar: 2, baz: 3, }, rest: { foo: 1, },}