# Advanced Pattern Search - Claude Code DevTools

Regex Pattern
Regex Flags
g - Global
i - Case Insensitive
m - Multiline
s - Dot All
u - Unicode

### Pattern Library - Click to Use

### Live Regex Tester

Test Text

## Search Results

0 matches found
Enter a pattern and search to see results

## About This Tool

### Purpose

Advanced Pattern Search is a power-user tool for performing sophisticated regex-based searches across Claude Code transcripts. It supports modern JavaScript regex features including lookahead/lookbehind assertions, named capturing groups, and all regex flags for maximum search precision.

### Features

- Advanced Regex Support - Lookahead, lookbehind, named groups, unicode escapes
- Real-time Validation - Live validation of regex patterns as you type
- All Regex Flags - Support for g, i, m, s, u flags with descriptions
- Pattern Library - Pre-built patterns for common searches (errors, files, code blocks)
- Capture Group Display - Visual highlighting of matched groups and named captures
- Live Regex Tester - Test patterns against sample text before searching
- Match Statistics - Count, position, and context for every match
- Export Capability - Export matches as JSON for further analysis

### Web Research Integration

Source: MDN - JavaScript Regular Expressions Guide

Techniques Applied:

- Lookahead/Lookbehind Assertions - Implemented positive/negative lookahead (`(?=...)`, `(?!...)`) and lookbehind (`(?<=...)`, `(?<!...)`) for context-aware matching without consuming characters
- Named Capturing Groups - Support for `(?<name>...)` syntax with visual display of named captures and backreferences `\k<name>`
- Modern Regex Flags - Complete flag support including dotAll mode (s flag) for matching newlines and unicode mode (u flag) for proper unicode handling

### Pattern Library Examples

- Error Messages - `(?<=Error:\s).*?(?=\n|$)` - Uses lookbehind to match text after "Error: " and lookahead to stop at newline
- File Paths - `(?<path>[\w/.-]+\.(?<ext>\w+))` - Named groups for full path and extension
- Code Blocks - ````(?<lang>\w+)\n(?<code>[\s\S]*?)```` - Named captures for language and code content
- URLs - `https?://(?<domain>[\w.-]+)(?<path>/[\w/.-]*)?` - Separate domain and path captures
- Email Addresses - `(?<user>[\w.+-]+)@(?<domain>[\w.-]+)` - User and domain named groups

### Usage

1. Enter Pattern - Type your regex pattern or select from the pattern library
2. Configure Flags - Select appropriate flags (global, case-insensitive, multiline, etc.)
3. Test Pattern - Use the live tester to verify your pattern works as expected
4. Search - Execute search against sample data or loaded transcript sessions
5. Analyze Results - Review matches with highlighted capture groups and context
6. Export - Export results as JSON for further processing

### Advanced Regex Tips

- Lookahead - `foo(?=bar)` matches "foo" only when followed by "bar", without consuming "bar"
- Lookbehind - `(?<=foo)bar` matches "bar" only when preceded by "foo"
- Negative Lookahead - `foo(?!bar)` matches "foo" NOT followed by "bar"
- Named Groups - `(?<year>\d{4})-(?<month>\d{2})` creates accessible named captures
- Lazy Quantifiers - Add `?` after `*` or `+` for minimal matching