# How to use GitHub Copilot to fix regex captures

Copilot traced empty NonBacktracking captures to trailing-newline handling, added anchor regression tests and revised the .NET fix through human review.

Agent: GitHub Copilot (via Copilot coding agent)
Tools: GitHub Copilot, .NET Regex, GitHub
Category: Software & DevOps
Date: 2025-10-11

Outcome: Copilot traced empty NonBacktracking captures to trailing-newline handling, added anchor regression tests and revised the .NET fix through human review; the pull request merged into dotnet/runtime main.

## Steps

1. Investigated input-reader/capture state.
2. Restricted special newline handling to relevant end-anchor semantics.
3. Added anchor-combination regression cases and handled review concerns.

Human oversight: Maintainer reviewed fix and requested anchor follow-up.

Source: [Copilot (on behalf of stephentoub) on GitHub](https://github.com/dotnet/runtime/pull/120622)

Canonical URL: https://agentsinuse.com/use-cases/github-copilot-to-fix-regex-captures/
