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
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' },
];Quick start
Section titled “Quick start”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.
Operators and state
Section titled “Operators and state”| UI mode | Saved operator | Value shape |
|---|---|---|
| Matches pattern | regexMatches | { pattern: string, flags: string } |
| Does not match pattern | regexNotMatches | { 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.
Restore a regular expression
Section titled “Restore a regular expression”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.
Validation and preview
Section titled “Validation and preview”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.
Common mistakes
Section titled “Common mistakes”- Escape backslashes for JavaScript strings. A regex digit class is written as
\\dinside the saved string. - Do not add unsupported flags such as
g,s, oru; onlyiandmare 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.