id | title |
---|---|
regexp |
RegExp |
The Hermes regexp engine is a traditional engine using a backtracking stack. It compiles a regexp into bytecode which can be executed efficiently. For regexp literals like /abc/
, this occurs at compile time: the regexp bytecode is embedded into the Hermes bytecode file. Note regexp bytecode is distinct from Hermes bytescode.
The regexp engine proceeds as follows:
- Parse phase. The regexp parser emits a tree of nodes, effectively an IR.
- Optimization phase. The node tree is traversed and optimized in various ways.
- Emitting phase. The node tree is traversed and emits regexp bytecode.
- Execution phase. The bytecode is executed against an input string.
As of this writing, Hermes regexp supports
- All of ES6, including global, case-insensitive, multiline, sticky, and Unicode (and legacy).
- ES9 lookbehinds.
- Named capture groups.
- Unicode property escapes.