regex-partial-match 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/index.js +14 -0
- package/package.json +3 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ISC License
|
|
2
2
|
|
|
3
|
-
Copyright 2025 Tom Pereira (https://github.com/TomStrepsil)
|
|
3
|
+
Copyright 2025-2026 Tom Pereira (https://github.com/TomStrepsil)
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ This allows the pattern to match prefixes of the original pattern, enabling vali
|
|
|
56
56
|
|
|
57
57
|
Since the library accepts only valid regular expressions [^1], this enables the algorithm to make lots of unguarded assumptions about the source of the expression.
|
|
58
58
|
|
|
59
|
-
The library has been stress-tested with various regular expression features in isolation, and some in likely combination, but obviously
|
|
59
|
+
The library has been stress-tested with various regular expression features in isolation, and some in likely combination, but obviously it's an unbounded test space, and syntactically valid regular expressions nevertheless support contradictory patterns e.g.
|
|
60
60
|
|
|
61
61
|
- `/\b\B/` - impossible to match both a word boundary and a non-word boundary
|
|
62
62
|
- `/$^/` - end cannot come before start
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var occurrencesRegex = /\{\d+,?\d*\}/g;
|
|
2
|
+
var notNumbersRegex = /\D/g;
|
|
2
3
|
var createPartialMatchRegex = function (regex) {
|
|
3
4
|
var source = regex.source;
|
|
4
5
|
var isUnicode = regex.unicode || regex.unicodeSets;
|
|
@@ -44,6 +45,19 @@ var createPartialMatchRegex = function (regex) {
|
|
|
44
45
|
case "x":
|
|
45
46
|
appendOptional(4);
|
|
46
47
|
break;
|
|
48
|
+
case "1":
|
|
49
|
+
case "2":
|
|
50
|
+
case "3":
|
|
51
|
+
case "4":
|
|
52
|
+
case "5":
|
|
53
|
+
case "6":
|
|
54
|
+
case "7":
|
|
55
|
+
case "8":
|
|
56
|
+
case "9":
|
|
57
|
+
notNumbersRegex.lastIndex = i + 1;
|
|
58
|
+
var nextNonDigit = notNumbersRegex.exec(source);
|
|
59
|
+
appendOptional((nextNonDigit ? nextNonDigit.index : source.length) - i);
|
|
60
|
+
break;
|
|
47
61
|
default:
|
|
48
62
|
appendOptional(2);
|
|
49
63
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "regex-partial-match",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A regular expression transform for partial matching",
|
|
5
5
|
"devEngines": {
|
|
6
6
|
"runtime": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"version": ">=23"
|
|
9
9
|
},
|
|
10
10
|
"packageManager": {
|
|
11
|
-
"name": "npm"
|
|
11
|
+
"name": "npm",
|
|
12
|
+
"version": "^11"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|