Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(functions): add support unicode to regexp pattern #2558

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/functions/src/__tests__/pattern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe('Core Functions / Pattern', () => {
it('should return empty array when given value does not match the given notMatch string regex with slashes and modifier', async () => {
expect(await runPattern('def', { notMatch: '/[abc]+/i' })).toEqual([]);
});

it('should support unicode', async () => {
expect(await runPattern('DüsseldorfKölnМосква北京市إسرائيل', { match: '^\\p{Letter}+$' })).toEqual([]);
expect(await runPattern('DüsseldorfKölnМосква北京市إسرائيل', { match: '/^\\p{Letter}+$/u' })).toEqual([]);
});
});

describe('given match and notMatch regexes', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createRegex(pattern: string): RegExp {
return new RegExp(splitRegex[1], splitRegex[2]);
} else {
// without slashes like [a-b]+
return new RegExp(pattern);
return new RegExp(pattern, 'u');
}
}

Expand Down