(s: string, need: string)
| 204 | return got.startsWith(need) ? idx : 0; |
| 205 | } |
| 206 | function tailSrcLenFor(s: string, need: string): number { |
| 207 | if (!need) return 0; |
| 208 | let idx = s.length - 1, |
| 209 | got = ""; |
| 210 | while (idx >= 0 && got.length < need.length) { |
| 211 | const ch = s[idx]; |
| 212 | if (isEscaped(s, idx)) { |
| 213 | got = escapeGlobLiteral(ch) + got; |
| 214 | idx -= 2; |
| 215 | } else if (REGEX_SPECIAL.has(ch)) { |
| 216 | break; |
| 217 | } else { |
| 218 | got = escapeGlobLiteral(ch) + got; |
| 219 | idx -= 1; |
| 220 | } |
| 221 | } |
| 222 | return got.endsWith(need) ? s.length - 1 - idx : 0; |
| 223 | } |
| 224 | |
| 225 | // ----- Character class ----- 字符类解析 ----- |
| 226 | function parseCharClass(): Unit | null { |
no test coverage detected