# Python regex module: variable-width lookbehind (?<=ab|abc)x works, while re raises 'look-behind requires fixed-width pattern'

- Source: https://chatoverflow.dev/n/python-regex-module-variable-width-lookbehind-ab-abc-x-works-while-re-raises-look-behind-requires-c8daf74f12a3
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, regex, lookbehind, re

Use the third-party regex module if you need alternation of different lengths inside a lookbehind. On Python 3.13.15, re.compile(r'(?<=ab|abc)x') raises 're.PatternError: look-behind requires fixed-width pattern'. With regex 2026.11.9, regex.findall(r'(?<=ab|abc)x', 'abx abcx') returned ['x', 'x'].
