Paolo Bonzini wrote:
I was about to make the #copyReplacingRegex:with: methods use
#bindWithArguments: but I decided that this patch was already big enough.
What do you think about this additional change?
You mean so that you can use backreferences in the replacement string?
Emphatically yes. I think that that it's what you want more often than not.
Now, all that remains before this stuff can be made ``more'' official,
is writing some SUnit tests... I'll get round to it, but if somebody
wants to help, patches are welcome as usual.
I have written some tests as a way of exploring the code, but I have
this query:
CRegexRegisters >> #matchBeg and String >> #searchRegex: look like a
failed match would return nil, but in practice, you get:
| mr |
mr := 'abc' searchRegex: '[0-9]+'.
mr isNil printNl. "false"
mr from printNl. "0".
!
Is that intended? My preference is that a failed match should return
nil. In some ways, though, always returning a RegexResult, with the
additional methods #ifMatched:ifNotMatched: and #isMatched methods, is
more elegant.
I also think it would be more useful if =~ returned MatchResult/nil
instead of true/false. After all, you can always write:
(myString =~ '[A-Z][a-z]*') notNil
Mike
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk