re2js 1.3.1 → 1.3.2
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/README.md +7 -3
- package/build/index.cjs.cjs +3 -3
- package/build/index.cjs.cjs.map +1 -1
- package/build/index.esm.js +3 -3
- package/build/index.esm.js.map +1 -1
- package/build/index.umd.js +3 -3
- package/build/index.umd.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -100,7 +100,9 @@ RE2JS.LONGEST_MATCH
|
|
|
100
100
|
|
|
101
101
|
### Checking for Matches
|
|
102
102
|
|
|
103
|
-
RE2JS allows you to check if a string matches a given regex pattern using the `matches()` function
|
|
103
|
+
RE2JS allows you to check if a string matches a given regex pattern using the `matches()` function.
|
|
104
|
+
|
|
105
|
+
***Performance Note:** The `matches()` method is highly optimized. It performs a strict anchored check and runs directly on the high-speed DFA (Deterministic Finite Automaton) engine without tracking capture groups or instantiating a stateful `Matcher` object.*
|
|
104
106
|
|
|
105
107
|
```js
|
|
106
108
|
import { RE2JS } from 're2js'
|
|
@@ -163,7 +165,7 @@ matchString.find(7) // false
|
|
|
163
165
|
|
|
164
166
|
### High-Performance Boolean Testing
|
|
165
167
|
|
|
166
|
-
If you only need to know **whether** a string matches a pattern (without extracting capture groups), you should use the `test()
|
|
168
|
+
If you only need to know **whether** a string matches a pattern (without extracting capture groups), you should use the `test()`, `testExact()`, or `matches()` methods. Unlike `.matcher()`, these methods do not instantiate stateful `Matcher` objects and request exactly `0` capture groups. This guarantees that execution is securely routed to the high-speed DFA (Deterministic Finite Automaton) engine whenever possible in linear `O(n)` time
|
|
167
169
|
|
|
168
170
|
#### `test(input)`
|
|
169
171
|
|
|
@@ -183,7 +185,9 @@ if (re.test('The system encountered a critical failure')) {
|
|
|
183
185
|
|
|
184
186
|
#### `testExact(input)`
|
|
185
187
|
|
|
186
|
-
Tests if the regular expression matches the entire input string (anchored to both start and end)
|
|
188
|
+
Tests if the regular expression matches the entire input string (anchored to both start and end).
|
|
189
|
+
|
|
190
|
+
*Note: `RE2JS.matches()` delegates to this method, so they provide the exact same performance and behavior.*
|
|
187
191
|
|
|
188
192
|
```js
|
|
189
193
|
import { RE2JS } from 're2js';
|
package/build/index.cjs.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* re2js
|
|
3
3
|
* RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
|
|
4
4
|
*
|
|
5
|
-
* @version v1.3.
|
|
5
|
+
* @version v1.3.2
|
|
6
6
|
* @author Alexey Vasiliev
|
|
7
7
|
* @homepage https://github.com/le0pard/re2js#readme
|
|
8
8
|
* @repository github:le0pard/re2js
|
|
@@ -6255,7 +6255,7 @@ class RE2JS {
|
|
|
6255
6255
|
* @throws RE2JSSyntaxException if the regular expression is malformed
|
|
6256
6256
|
*/
|
|
6257
6257
|
static matches(regex, input) {
|
|
6258
|
-
return RE2JS.compile(regex).
|
|
6258
|
+
return RE2JS.compile(regex).testExact(input);
|
|
6259
6259
|
}
|
|
6260
6260
|
|
|
6261
6261
|
/**
|
|
@@ -6321,7 +6321,7 @@ class RE2JS {
|
|
|
6321
6321
|
* @returns {boolean} true if the regular expression matches the entire input
|
|
6322
6322
|
*/
|
|
6323
6323
|
matches(input) {
|
|
6324
|
-
return this.
|
|
6324
|
+
return this.testExact(input);
|
|
6325
6325
|
}
|
|
6326
6326
|
|
|
6327
6327
|
/**
|