regexp: how to match a null string?
Fri Mar 28 01:54:53 CET 2003
The regexp behaviour seems very weird to me.
In my mind, "^(.*)$" should match a null string.
It doesn't match any characters, but it's still a valid match.
But because regexp deals only in terms of characters matched -
there's no way to tell!
Erlang (BEAM) emulator version 184.108.40.206 [source] [hipe]
Eshell V220.127.116.11 (abort with ^G)
1> S = "".
2> P = "^(.*)$".
3> regexp:match(S, P).
4> regexp:first_match(S, P).
5> regexp:matches(S, P).
6> regexp:matches("foo", "bar").
Would anyone else be interested in a function like
regexp:is_match(String, RegExp) -> true | false
? Or is there a better way to solve this problem?
More information about the erlang-questions