We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7eb46aa + bf5e456 commit df50c8bCopy full SHA for df50c8b
src/TextInputMask.tsx
@@ -7,6 +7,10 @@ function detectCharacter(mask: string): string {
7
return c || ''
8
}
9
10
+function escapeForRegExp(value: string): string {
11
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
12
+}
13
+
14
function TextInputWithMask(
15
{
16
onChangeText,
@@ -40,7 +44,7 @@ function TextInputWithMask(
40
44
)
41
45
const replaceValue = format.match(/\W/)
42
46
const replace = `$1${splitCharacter}$2${splitCharacter}$3$4`.replace(
43
- new RegExp(splitCharacter, 'g'),
47
+ new RegExp(escapeForRegExp(splitCharacter), 'g'),
48
(replaceValue ?? '') as string
49
50
0 commit comments