Skip to content

Commit d0368d1

Browse files
Richard Carlssonnwolverson
authored andcommitted
Use modern Erlang string functions in Data.String.Regex
Drop use of obsolete string:chr().
1 parent 0601c7d commit d0368d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Data/String/Regex.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ flags_to_options([$y|Flags], Acc) -> flags_to_options(Flags, [anchored|Acc]); %%
1212
flags_to_options([$u|Flags], Acc) -> flags_to_options(Flags, [ucp|[unicode|Acc]]);
1313
flags_to_options(_,_) -> err.
1414

15-
is_global(S) -> case string:chr(unicode:characters_to_list(S), $g) of
16-
0 -> false;
15+
is_global(S) -> case string:find(S, <<"g"/utf8>>) of
16+
nomatch -> false;
1717
_ -> true
1818
end.
1919

@@ -55,6 +55,7 @@ end.
5555
replace({R,{_,F}},S1,S2) ->
5656
G = case is_global(F) of true -> [global]; false -> [] end,
5757
re:replace(S2,R,S1,G++[{return,binary}]).
58+
5859
% TODO
5960
'_replaceBy'(_Just,_Nothing,{_R,_},_F,_S2) -> error("_replaceBy not supported").
6061

0 commit comments

Comments
 (0)