patternHasCaptureGroup reports whether a regex literal contains an unescaped capturing '(' (i.e. '(' not preceded by '\' and not the start of '(?').
(p string)
| 320 | // patternHasCaptureGroup reports whether a regex literal contains an unescaped |
| 321 | // capturing '(' (i.e. '(' not preceded by '\' and not the start of '(?'). |
| 322 | func patternHasCaptureGroup(p string) bool { |
| 323 | for i := 0; i < len(p); i++ { |
| 324 | if p[i] == '\\' { |
| 325 | i++ |
| 326 | continue |
| 327 | } |
| 328 | if p[i] == '(' && (i+1 >= len(p) || p[i+1] != '?') { |
| 329 | return true |
| 330 | } |
| 331 | } |
| 332 | return false |
| 333 | } |
| 334 | |
| 335 | // intervalReturningFuncs are compat/native functions whose result is an INTERVAL, |
| 336 | // used to recognise a provably-interval argument to isfinite(). |