-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add vertical tab support to Regex.Escape #123081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for escaping the vertical tab character (\v) in Regex.Escape, completing the functionality that was already present in Regex.Unescape. This change builds on PR #120625, which added vertical tab support to the regex parser for IgnorePatternWhitespace.
Changes:
- Added vertical tab (
\v) handling inRegexParser.EscapeImplto escape the character as\v - Changed
ScanCharEscapeto use\vliteral instead of\u000Bfor consistency - Updated comment to document
\vas part of whitespace characters - Added comprehensive tests for both
EscapeandUnescapewith vertical tab
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Regex.EscapeUnescape.Tests.cs | Added new test methods Escape_VerticalTab and Unescape_VerticalTab to verify vertical tab escaping/unescaping behavior |
| RegexParser.cs | Added case for \v in EscapeImpl, changed \u000B to \v in ScanCharEscape, and updated whitespace comment |
...libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.EscapeUnescape.Tests.cs
Show resolved
Hide resolved
...libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.EscapeUnescape.Tests.cs
Show resolved
Hide resolved
There are many more characters Unescape recognizes that Escape doesn't. Why is this one in particular important to add to Escape? |
|
In #120625, The mention of |
|
It was unintended for Regex.Escape to be impacted by that PR. I'll fix it. Thanks. |
Add support for escaping vertical tab character (
\v) inRegex.Escape.Regex.Unescapealready supported\v, butRegex.Escapewas missing this functionality.\vcharacter (0x0B) inRegexParser.EscapeImpl\vinstead of\u000BinRegexParser.ScanCharEscapeRegex.Escape/UnescapeRelated to PR #120625