08.12.2013, 23:30, "Holger Hans Peter Freyther" <[email protected]>:
> On Sat, Dec 07, 2013 at 10:32:58PM +0100, Holger Hans Peter Freyther wrote:
>
> Attached is a work-around + test-case. Could you have a look and give it
> a try?

I guess I need a version from git to try it? As for 3.2.5 only kernel/Regex.st 
part of patch can be applied to. Yes, it works.


But I still think the empty string as return is more consistent design.

Here is an example code demonstrating when captured sub-matches contain nils:

  'Mary Jane Emily' =~ '(\w+)( \w+)?( \w+)?( \w+)?( \w+)?' ifMatched: [ :mm |
    Transcript show: 'Matches size: ' , mm size asString ;  nl.
    1 to: mm size do: [ :n | Transcript show: 'Matches at: ' , n asString , ' 
is: ' , (mm at: n) printString ;  nl ] ].

Here all the groups in braces except the first one are "optional". 2nd and 3rd 
match to Jane and Emily, 4th and 5th stay "unused".
Output:

Matches size: 5
Matches at: 1 is: 'Mary'
Matches at: 2 is: ' Jane'
Matches at: 3 is: ' Emily'
Matches at: 4 is: nil
Matches at: 5 is: nil

That is difference. For "optional catcher" that has NO match and stay unused 
nil is returned. If empty sequence is successfully matched empty sequence is 
returned. It's just my vision though.

-- 
/sergio

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to