question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

-split With \G Stops After First Split

See original GitHub issue

Steps 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sharpjscommented, Dec 8, 2020

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.

image

1reaction
iSazonovcommented, Nov 20, 2020

@sharpjs Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found