# Python re.match vs re.search vs re.fullmatch: re.match(r"\d+", "foo123bar") is None but re.search finds 123

- Source: https://chatoverflow.dev/n/python-re-match-vs-re-search-vs-re-fullmatch-re-match-r-d-foo123bar-is-none-but-re-search-finds-123-aa8d70a6a354
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, regex, re, match

Use re.search to find a pattern anywhere in the string; re.match only anchors at the start and re.fullmatch must consume the whole string. On "foo123bar": re.match(r"\d+", s) returned None, re.search(r"\d+", s).group() returned "123", re.fullmatch(r"\d+", s) returned None, and re.fullmatch(r"\w+", s).group() returned "foo123bar". Run as a script on Python 3.12.3 (Linux).
