Skip to content

Regular Expression Filter

Use the Regular Expression filter when users need an explicit text pattern, such as an invoice prefix, an email domain, or a controlled identifier format.

Source code
TypeScriptts
grid.plugins = [AdvanceFilterPlugin];
grid.columns = [
  {
    prop: 'invoiceId',
    name: 'Invoice ID',
    filter: ['string', FILTER_REGEX],
  },
];
grid.filter = true;

return [
  { invoiceId: 'INV-123456' },
  { invoiceId: 'INV-654321' },
  { invoiceId: 'INV-12345' },
  { invoiceId: 'PO-123456' },
  { invoiceId: 'inv-112233' },
];
import { AdvanceFilterPlugin, FILTER_REGEX } from '@revolist/revogrid-pro';
import '@revolist/revogrid-pro/dist/revogrid-pro.css';
grid.plugins = [AdvanceFilterPlugin];
grid.columns = [
{ prop: 'invoiceId', name: 'Invoice ID', filter: ['string', FILTER_REGEX] },
];
grid.filter = true;

The popup validates the pattern before committing it and previews matching unique values.

UI modeSaved operatorValue shape
Matches patternregexMatches{ pattern: string, flags: string }
Does not match patternregexNotMatches{ pattern: string, flags: string }

Supported flags are i for case-insensitive matching and m for multiline anchors. Flags are normalized into stable im order and duplicates are removed.

grid.filter = {
multiFilterItems: {
invoiceId: [
{
id: 1,
type: 'regexMatches',
value: { pattern: '^INV-\\d{6}$', flags: 'i' },
relation: 'and',
},
],
},
};

An empty pattern removes the condition. Invalid patterns remain in the editor without replacing the last valid condition.

RevoGrid rejects invalid expressions and common nested-quantifier patterns that can cause catastrophic backtracking. The preview shows two matching unique values by default and scans at most 10,000 unique scalar values. Matching uses parsed scalar values; null, undefined, objects, and functions do not match either operator.

For remote or partially loaded rows, provide complete unique-value aggregates when the preview must describe the full result set. The saved pattern and flags remain the remote execution contract.

  • Escape backslashes for JavaScript strings. A regex digit class is written as \\d inside the saved string.
  • Do not add unsupported flags such as g, s, or u; only i and m are retained.
  • Do not expect an invalid edit to clear a working filter; the last valid condition stays active.
  • Do not use arbitrary user-supplied patterns without considering backend regex compatibility when filtering remotely.