-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enhance -split operator with RightToLeft splitting (#2) #5270
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
Modified existing test that assumes Max-substrings = 0 when negative. Added tests for scriptblock/predicate-based splitting (regular and right-to-left).
To allow RTL splitting when supplying negative Max-substrings arguments to -split, we set the RightToLeft RegexOption and convert limit to an absolute value
Additionally changed the chunk buffer from StringBuilder to List<char> - we don't use any StringBuilder specific functionality and List<char> allows us to reverse the chunk and avoid Insert(0, item) The individual chunk lists have been changed to pre-allocate the expected needed capacity to avoid unnecessary resizing of the unuderlying array
|
@IISResetMe I see we could make some optimizations in the code. But your code works well and we can merge. What are your plans? If you want stop and merge I'll ask only some style comments. |
|
@iSazonov depends on the extent of your suggested optimizations :-) I've already included the list allocation changes from the previous PR |
|
We can exclude |
|
@iSazonov I've already removed the |
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
|
Closing this for now to avoid too many merge conflicts, will resubmit a new PR when I find the time |
This pull request adds RightToLeft support to the binary -split operator, as requested in #4765
I've added tests for negative integer input for the Max-substrings operand to work with both regex patterns and scriptblocks.
(Originally submitted as #5125, submitted anew due to completely botched rebase of the original branch)