dots in regexps

Fredrik Thulin ft@REDACTED
Tue Mar 30 13:59:47 CEST 2010


Hi

This surprises me :

1> re:replace("123foobar456", ".*foo(...)", "foo\\1", [{return, list}]).
"foobar456"

I would have expected "foobar", because in my book a dot matches a
single character.

Adding .* after the parentheses gives me "foobar", but I don't think it
should be necessary.

2> re:replace("123foobar456", ".*foo(...).*", "foo\\1",
		[{return, list}]).
"foobar"

Erlang R13B04 (erts-5.7.5)

/Fredrik




More information about the erlang-questions mailing list