Skip to content

Commit 023f115

Browse files
committed
add how to use safe-regex check
1 parent 44c702c commit 023f115

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

readme.md

+9-18
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,68 @@
1+
##Using safe-regex to check your patterns
2+
3+
1.`npm i`
4+
5+
2.you should add your custom patterns in safe.js file, and in `patterns` object.
6+
7+
3.`node safe.js`
8+
9+
110
##Safe Patterns
211

312
* en_label :
4-
513
`/^[a-zA-Z0-9-_ ]{0,250}$/`
614

715
* unicode_label :
8-
916
`/^[\s\w\u0600-\u06FFs]{0,250}$/`
1017

1118
* label :
12-
1319
`/^[\s\w\u0600-\u06FFs]{0,250}$/`
1420

1521
* publicKey :
16-
1722
`/^[\s\d\w]{0,3000}$/`
1823

1924
* description :
20-
2125
`/^[\s\w\u0600-\u06FFs]{0,5000}$/`
2226

2327
* email :
24-
2528
`/^[\w-.]{1,50}@[\w-.]{1,50}\.[\w-.]{1,50}$/`
2629

2730
* mobile :
28-
2931
`/^((\+[0-9]{1,2})|0)9[0-9]{9}$/`
3032

3133
* number :
32-
3334
`/^[0-9]*$/`
3435

3536
* complexWord :
36-
3737
`/^[\s\d\w\u0600-\u06FFs_+=:!@#$%^&*()+.\/\/-]*$/`
3838

3939
* password :
40-
4140
`/^[\s\d\w\u0600-\u06FFs_+=:;!@#$%^&*()+<>,.\/-]{8,16}$/`
4241

4342
* password16 :
44-
4543
`/^[\s\d\w\u0600-\u06FFs_+=:;!@#$%^&*()+<>,.\/\/-]{16,32}$/`
4644

4745
* passwordN :
48-
4946
`/^[\s\d\w\u0600-\u06FFs_+=:;!@#$%^&*()+<>,.\/\/-]{8,}$/`
5047

5148
* alphaNumeric :
52-
5349
`/^[\w\d]+$/`
5450

5551
* license :
56-
5752
`/^[\w\d]{25}$/`
5853

5954
* vpnHexKey :
60-
6155
`/^[a-fA-F\d]{64}$/`
6256

6357
* vpnHexIV :
64-
6558
`/^[a-fA-F\d]{32}$/`
6659

6760
* vpnPassword :
68-
6961
`/^[A-Za-z0-9@#$%^&!+=]{8,16}$/`
7062

7163
##Un-Safe Patterns
7264

7365
###Use Atomic group to solve this(or use `re2` or `validator.js`)
7466

7567
* link :
76-
7768
`/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/`

safe.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ var safe = require('safe-regex');
44
// console.log(safe(regex));
55
const showPatterns = (arr) => {
66
arr.forEach(pattern => {
7-
// console.log("\r\n*", pattern[0], ":\r\n")
8-
// console.log(" `" + prepareRegexObject(pattern[1]) + "`", "\r\n")
7+
// console.log("\r\n*", pattern[0], ":")
8+
// console.log(" `" + prepareRegexObject(pattern[1]) + "`")
99

1010
console.log("\r\n", pattern[0], "=>", "safe:", pattern[2])
1111
console.log(prepareRegexObject(pattern[1]), "\r\n")

0 commit comments

Comments
 (0)