We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When the \G anchor is used in a (?<=...) construct, the Regex.Split(string, string) method stops splitting after the first item.
\G
(?<=...)
Regex.Split(string, string)
This bug is also exposed in PowerShell 7.1.0: PowerShell/PowerShell#14112
Regex.Split("aabbccdd", @"(?<=\G..)(?=..)")
{ "aa", "bb", "cc", "dd" }
{ "aa", "bbccdd" }
To reproduce, clone sharpjs/Net50RegexSplitBug and run tests.
.NET 5.0.100 Windows 20H2 (OS Build 19042.630) x64 Not specific to this configuration; easily reproducible using PowerShell 7.1.0 on Linux.
docker run -it --rm mcr.microsoft.com/powershell:preview
[regex]::Split("aabbccdd", "(?<=\G..)(?=..)")
Yes, in .NET 5.0.100.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @eerhardt, @pgovind, @jeffhandley See info in area-owners.md if you want to be subscribed.
area-System.Text.RegularExpressions, untriaged
area-System.Text.RegularExpressions
untriaged
Sorry, something went wrong.
Thanks for the repro. This is a one-line fix. I'll put up a PR tonight.
stephentoub
Successfully merging a pull request may close this issue.
Description
When the
\G
anchor is used in a(?<=...)
construct, theRegex.Split(string, string)
method stops splitting after the first item.This bug is also exposed in PowerShell 7.1.0: PowerShell/PowerShell#14112
Example
{ "aa", "bb", "cc", "dd" }
{ "aa", "bbccdd" }
{ "aa", "bb", "cc", "dd" }
Reproduction
To reproduce, clone sharpjs/Net50RegexSplitBug and run tests.
Configuration
.NET 5.0.100
Windows 20H2 (OS Build 19042.630) x64
Not specific to this configuration; easily reproducible using PowerShell 7.1.0 on Linux.
Regression?
Yes, in .NET 5.0.100.
The text was updated successfully, but these errors were encountered: