Skip to content

Commit f7c0dda

Browse files
authored
feat(regex): add alphanumdashunderscoredotsparenthesis regex (#1126)
1 parent 1277aeb commit f7c0dda

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/regex/src/__tests__/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
alphanumdashdotsspaces,
1616
alphanumdashorempty,
1717
alphanumdashspaces,
18+
alphanumdashunderscoredotsspacesparenthesis,
1819
alphanumdots,
1920
ascii,
2021
backupKey,
@@ -40,6 +41,7 @@ import {
4041
} from '..'
4142

4243
const alphanumdashdotsText = 'testwithdashdots-.'
44+
const alphanumdashunderscoredotsparenthesisText = 'testwithdashdots-_. ()'
4345
const alphanumdashText = 'testwithdash-'
4446
const asciiLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
4547
const asciiLowercase = 'abcdefghijklmnopqrstuvwxyz'
@@ -254,6 +256,30 @@ describe('@regex', () => {
254256
})
255257
})
256258

259+
describe('alphanumdashunderscoredotsspacesparenthesis', () => {
260+
test.each([
261+
[alphanumdashText, true],
262+
[alphanumdashdotsText, true],
263+
[alphanumdashunderscoredotsparenthesisText, true],
264+
[asciiLetters, true],
265+
[asciiLowercase, true],
266+
[asciiUppercase, true],
267+
[digitsTest, true],
268+
[emailTest, false],
269+
[octdigits, true],
270+
[hexdigits, true],
271+
[printable, false],
272+
[punctuation, false],
273+
[whitespace, true],
274+
[cronTest, false],
275+
[macAddress1, false],
276+
])('should match regex %s to be %s', (string, expected) => {
277+
expect(alphanumdashunderscoredotsspacesparenthesis.test(string)).toBe(
278+
expected,
279+
)
280+
})
281+
})
282+
257283
describe('alphanumdashorempty', () => {
258284
test.each([
259285
[alphanumdashText, true],

packages/regex/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export const alphanumdash = /^[a-zA-Z0-9-]*$/
66
export const alphanumdashdots = /^[a-zA-Z0-9-.]*$/
77
export const alphanumdashdotsorempty = /^$|^[a-zA-Z0-9-.]*$/
88
export const alphanumdashdotsspaces = /^[a-zA-Z0-9-.\s]*$/
9+
export const alphanumdashunderscoredotsspacesparenthesis =
10+
/^[a-zA-Z0-9-_.()\s]*$/
11+
912
export const alphanumdashorempty = /^$|^[a-zA-Z0-9-]*$/
1013
export const alphanumdashspaces = /^[a-zA-Z0-9-\s]*$/
1114
export const alphanumdots = /^[a-zA-Z0-9.]*$/

0 commit comments

Comments
 (0)