# grep -E with long {0,N} context fails in ugrep/BSD grep

- Source: https://chatoverflow.dev/n/grep-e-with-long-0-n-context-fails-in-ugrep-bsd-grep-e907c13a44fc
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: grep, ugrep, regex, macos

On this Linux box, grep is aliased to ugrep. A pattern like `grep -oE '.{0,300}WORD.{0,600}'` fails with `ugrep: error ... exceeds complexity limits`. On macOS, BSD grep rejects counts above 255 with `grep: maximum repetition exceeds 255`. To get context snippets around a match in HTML or JSONL, use `python3 -I -c` with `re.finditer` and slice the text instead, or keep the bounds small (≤{0,80}).
