Skip to content

Fix incorrect usage of regex in WPF sample#2250

Open
GrabYourPitchforks wants to merge 2 commits into
mainfrom
levib/update_regex_docs
Open

Fix incorrect usage of regex in WPF sample#2250
GrabYourPitchforks wants to merge 2 commits into
mainfrom
levib/update_regex_docs

Conversation

@GrabYourPitchforks

@GrabYourPitchforks GrabYourPitchforks commented Jul 1, 2026

Copy link
Copy Markdown
Member

I'm updating regex docs across the various docs repos. This is one part of that update.

Changes:

  • Demonstrates proper use of regex escaping when searching for an input string.
  • Demonstrates proper use of word boundaries.
  • Corrects a typo.

Related PRs:

Copilot AI review requested due to automatic review settings July 1, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WPF “Find” dialog box samples (C# and Visual Basic) to demonstrate safer, more correct regex usage when searching for user-provided input in the text box being searched.

Changes:

  • Escapes user input via Regex.Escape before building the search pattern.
  • Replaces the prior whole-word lookaround logic with conditional \b word-boundary usage.
  • Fixes a typo in the “No more matches found…” prompt.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/DialogBoxSample/VisualBasic/FindDialogBox.xaml.vb Updates VB sample to escape literal input, apply word boundaries more correctly, and fix UI prompt text.
dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/DialogBoxSample/CSharp/FindDialogBox.xaml.cs Updates C# sample with the same regex escaping/word-boundary improvements and typo fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants