Fix binary:matches/2,3 when called on empty binary

Thomas Lachmann <>
Tue Nov 16 23:31:08 CET 2010


Hello,
binary:matches doesn't always work as documented, as a consequence
binary:replace might misbehave, too.

Example:

Current behaviour:

1> binary:matches(<<>>, <<"1">>).
nomatch
2> binary:replace(<<>>, <<"1">>, <<"2">>, [global]).
** exception error: bad argument
     in function  binary:replace/4

New behaviour:

1> binary:matches(<<>>, <<"1">>).
[]
2> binary:replace(<<>>, <<"1">>, <<"2">>, [global]).
<<>>

Contents of the branch:
- Changing a test which assumed binary:matches should return nomatch
- Add above example of re:replace/4 as test
- Fix source to behave as documented


git fetch git://github.com/thlachmann/otp.git binary_matches_fix


Regards,
Thomas


More information about the erlang-patches mailing list