-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Enhance the -split operator with negative maximum token counts to split from the end #4765
Copy link
Copy link
Closed
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semanticsparser, language semantics
Metadata
Metadata
Assignees
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semanticsparser, language semantics
As approved in #4721 (comment), and later amended in #5125 (comment):
After the enhancement, only a
<Max-substrings>value of0will be accepted as the explicit signal that all tokens should be returned, however many are found in the input string(s).Negative
<Max-substrings>values will work analogously to the already supported positive values, except that:they return the specified number of strings from the end of the string(s).
all individually extracted tokens are returned in input order, and whatever unsplit part remains, if any, is returned as the first token.
Examples:
Note that both
-split ' ', 1and-split ' ', -1are no-ops: they request no splitting at all, and the sign of the<Max-substrings>argument is therefore irrelevant.Reporting the prefix (unsplit part) first enables the following idiom:
Environment data