diff options
author | Björn Gustavsson <[email protected]> | 2011-08-25 14:02:43 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-10-26 15:44:01 +0200 |
commit | b22894a3b82675d88b06428fe38eceeef8ca3870 (patch) | |
tree | 3a99eefe169cff60e9f2278a0c66032440485b1f /lib/tv/src/tv_db_search.erl | |
parent | 9e034e51ca0f051b62e389545b3f5a56b9cec393 (diff) | |
download | otp-b22894a3b82675d88b06428fe38eceeef8ca3870.tar.gz otp-b22894a3b82675d88b06428fe38eceeef8ca3870.tar.bz2 otp-b22894a3b82675d88b06428fe38eceeef8ca3870.zip |
tv: Eliminate use of deprecated regexp module
Diffstat (limited to 'lib/tv/src/tv_db_search.erl')
-rw-r--r-- | lib/tv/src/tv_db_search.erl | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/lib/tv/src/tv_db_search.erl b/lib/tv/src/tv_db_search.erl index edd3c188e2..7634bc63b6 100644 --- a/lib/tv/src/tv_db_search.erl +++ b/lib/tv/src/tv_db_search.erl @@ -244,10 +244,10 @@ get_entry_text() -> string_to_regexp(Str) -> - case regexp:parse(Str) of + case re:compile(Str) of {ok, RegExp} -> {ok, RegExp}; - _Error -> + {error, _Error} -> case get(error_msg_mode) of normal -> {error, {not_a_regexp, "Please enter a regular expression!"}}; @@ -410,33 +410,11 @@ search_for_regexp(Pattern, Elem, ListAsStr) -> lists:flatten(tv_io_lib:write(Elem)) end, - case regexp:first_match(ListToSearch, Pattern) of - {match, _, _} -> + case re:run(ListToSearch, Pattern, [{capture,none}]) of + match -> found; - _Other -> + nomatch -> not_found - %% The code below shall be used instead if it is desired to - %% compare each *element* in the tuples to the regular expression, - %% i.e., treat each element as a new line/string. - %% The difference is most easily explained through an example: - %% If we treat each tuple as a new line/string, the regular expression - %% "^{win" will match the string "{win, 1, 2, 3}", but not the string - %% "{1, {win,2}}". - %% If we treat each element as a new line/string, the RE "^{win" will match - %% both strings above. - - %% SearchList = tuple_to_list(Elem), - %% case lists:dropwhile( - %% fun(H) -> - %% nomatch == regexp:first_match(lists:flatten(io_lib:write(H)), - %% Pattern) - %% end, - %% SearchList) of - %% [] -> - %% not_found; - %% _AnyList -> - %% found - %% end end. |