-split With \G Stops After First Split
See original GitHub issueSteps to reproduce
"ABCDEFGH" -split '(?<=\G..)(?=..)'
Expected behavior
In PS 7.0.3 and earlier, this is the output:
AB
CD
EF
GH
Actual behavior
In PS 7.1.0, this is the output:
AB
CDEFGH
Workaround
This works in PS 7.1.0:
[regex]::Matches("ABCDEFGH", "..") | % Value
Environment data
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
java - How does \G work in .split?
I know \G is used to stop after a non-match is encountered. EDIT: \G is used to indicate the position where the last...
Read more >What is the Split-Sleeper Berth Exception?
Two separate qualifying break periods can be combined to obtain at least 10 hours off duty, and both periods will pause the 14-hour...
Read more >What's the best way to join files again after splitting them?
There is no more efficient way than copying the first file, then copying the second file after it, and so on. Both DOS...
Read more >Split string into array of characters - empty delimiter not working
Solved: Trying to split a string into an array of characters, but using a delimiter of nothing ' ' does not work. Any...
Read more >String.prototype.split() - JavaScript - MDN Web Docs - Mozilla
The split() method of String values takes a pattern and divides this string into an ordered list of substrings by searching for the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The fix is not documented to be in .NET 5.0.1 as of this writing, but my repro test went from red to green with the installation of .NET 5.0.1. So, looks like upstream is fixed.
@sharpjs Thanks!