Christoph Thiede uploaded a new version of Regex-Core to project The Trunk: http://source.squeak.org/trunk/Regex-Core-ct.89.mcz
==================== Summary ====================
Name: Regex-Core-ct.89 Author: ct Time: 1 May 2024, 6:10:49.419117 pm UUID: d2c4145b-80ff-4c4f-baa6-7fcd9f929a42 Ancestors: Regex-Core-ct.87
Fixes and documents order of keyed subexpressions to be top-down and left-to-right (complements Regex-Tests-Core-ct.36). Documents index offset in positional #subexpression: and #subexpressions:.
=============== Diff against Regex-Core-ct.87 ===============
Item was changed: ----- Method: RxMatcher>>keyedSubexpressionRanges: (in category 'accessing') ----- keyedSubexpressionRanges: key + "Answer an array of all match ranges (inclusiveStart -> inclusiveStop) of the subexpression at the given key. If a key is defined in multiple groups, sort ranges top-down and left-to-right." - "Answer an array of all match ranges (inclusiveStart -> inclusiveStop) of the subexpression at the given key."
^ ((keyedMarkerPositions at: key) gather: [:pair | (markerPositions at: pair first) with: (markerPositions at: pair second) collect: [:start :stop | start + 1 to: stop]]) "Since the same key can be defined for multiple markers, ordering the matches is non-trivial." + reverse sort: [:range | range start] ascending! - sort: [:range | range stop] ascending!
Item was changed: ----- Method: RxMatcher>>subexpression: (in category 'accessing') ----- subexpression: subIndex "Answer a string that matched the subexpression at the given index. If there are multiple matches, answer the last one. If there are no matches, answer nil. + NB: index 1 is the entire match, index 2 is the first capture group, etc. (NB: it used to answer an empty string but I think nil makes more sense)."
^ (self subexpressions: subIndex) ifNotEmpty: [:expressions | expressions last] ifEmpty: [nil]!
Item was changed: ----- Method: RxMatcher>>subexpressions: (in category 'accessing') ----- subexpressions: subIndex "Answer an array of all matches of the subexpression at the given index. + The answer is always an array; it is empty if there are no matches. + NB: index 1 is the entire match, index 2 is the first capture group, etc." - The answer is always an array; it is empty if there are no matches."
| originalPosition startPositions stopPositions reply | originalPosition := stream position. startPositions := self subBeginning: subIndex. stopPositions := self subEnd: subIndex. (startPositions isEmpty or: [stopPositions isEmpty]) ifTrue: [^Array new]. reply := Array new: startPositions size. 1 to: reply size do: [ :index | | start stop | start := startPositions at: index. stop := stopPositions at: index. stream position: start. reply at: index put: (stream next: stop - start) ]. stream position: originalPosition. ^reply!
packages@lists.squeakfoundation.org