This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // got the idea while answering https://stackoverflow.com/questions/79534604/regular-expressions-loop-code-how-backtracking-works | |
| /** | |
| * @callback MatchCallback sub-match | |
| * @param {string | ArrayLike<string>} text - string or list of characters (`{length: number, [index: number]: string}`) | |
| * @param {number} index - index into `text` (safe integer; can be out of range) | |
| * @returns {number} new `index` (safe integer; unchanged if empty match) | |
| * @throws {TypeError} if {@linkcode index} is not a safe integer | |
| * @throws {TypeError} if {@linkcode text} is not a string nor a list of characters (`{length: number, [index: number]: string}` and entries are not empty) | |
| * @throws {typeof Backtracking} if match fails ! (other errors should be thrown again and not silenced) |