# AssertionError: Regex pattern '\d+' does not match 'abc'.
assert regex_search('\d+', 'abc')

- **ID:** `python/pytest-assert-regex-mismatch`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test using pytest's `re.match` or `assert re.search` fails because the string does not contain the expected pattern, often due to incorrect regex or wrong input.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Test the regex separately: `import re; assert re.search(r'\d+', 'abc123')` to verify the pattern works.
   ```
2. **** (95% success)
   ```
   Use raw strings for regex patterns to avoid escape issues: `r'\d+'`
   ```

## Dead Ends

- **** — This may not capture the exact pattern requirements and can lead to false passes. (70% fail)
- **** — This makes the test useless as it matches anything, defeating the purpose of validation. (85% fail)
