Fix regexes: "\." becomes "\\."

This commit is contained in:
Jean-Sébastien Pédron 2012-11-16 14:24:00 +01:00
parent 7930aa8759
commit 5da1810828
2 changed files with 3 additions and 2 deletions

View File

@ -93,7 +93,7 @@ string_to_float(Text) ->
string_to_float2(Text) ->
Opts = [{capture, none}],
Ret = re:run(Text, "^(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$",
Ret = re:run(Text, "^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$",
Opts),
case Ret of
match -> erlang_list_to_float(Text);

View File

@ -83,7 +83,8 @@ string_to_float(Text) ->
string_to_float2(Text) ->
Opts = [{capture, none}],
case re:run(Text, "^(0|[1-9][0-9]*)(\.[0-9]*)?([eE][-+]?[0-9]+)?$", Opts) of
Ret = re:run(Text, "^(0|[1-9][0-9]*)(\\.[0-9]*)?([eE][-+]?[0-9]+)?$", Opts),
case Ret of
match -> yamerl_node_float:erlang_list_to_float(Text);
nomatch -> error
end.