MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / match

Method match

src/compute-engine/latex-syntax/tokenizer.ts:168–187  ·  view source on GitHub ↗

* Return the next substring matching regEx and advance.

(regEx: RegExp)

Source from the content-addressed store, hash-verified

166 /**
167 * Return the next char and advance
168 */
169 get(): string {
170 return this.pos < this.s.length ? this.s[this.pos++] : '';
171 }
172 /**
173 * Return the next char, but do not advance
174 */
175 peek(): string {
176 return this.s[this.pos];
177 }
178 /**
179 * Return the next substring matching regEx and advance.
180 */
181 match(regEx: RegExp): string | null {
182 // this.s can either be a string, if it's made up only of ASCII chars
183 // or an array of graphemes, if it's more complicated.
184 //
185 // Use a sticky variant of the regex positioned at the current offset,
186 // rather than slicing the remaining input (O(n) per token, O(n²) total).
187 const re = stickyRegex(regEx);
188 if (typeof this.s === 'string') {
189 re.lastIndex = this.pos;
190 } else {

Callers 1

nextMethod · 0.95

Calls 1

stickyRegexFunction · 0.85

Tested by

no test coverage detected