/modules/mod_base/filters/filter_match.erl

https://code.google.com/p/zotonic/ · Erlang · 33 lines · 12 code · 5 blank · 16 comment · 0 complexity · 9b2a81c9e880d711f78f9a7d2974dc7c MD5 · raw file

  1. %% @author Maas-Maarten Zeeman <mmzeeman@xs4all.nl>
  2. %% @copyright 2010 Maas-Maarten Zeeman
  3. %% @doc 'match' match a value. returns true if the value matches the regular expression.
  4. %% Copyright 2011 Maas-Maarten Zeeman
  5. %%
  6. %% Licensed under the Apache License, Version 2.0 (the "License");
  7. %% you may not use this file except in compliance with the License.
  8. %% You may obtain a copy of the License at
  9. %%
  10. %% http://www.apache.org/licenses/LICENSE-2.0
  11. %%
  12. %% Unless required by applicable law or agreed to in writing, software
  13. %% distributed under the License is distributed on an "AS IS" BASIS,
  14. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. %% See the License for the specific language governing permissions and
  16. %% limitations under the License.
  17. -module(filter_match).
  18. -export([match/3]).
  19. -author('mmzeeman@xs4all.nl').
  20. match(S, Re, _Context) ->
  21. case re:run(S, Re) of
  22. match ->
  23. true;
  24. nomatch ->
  25. false;
  26. {match, _} ->
  27. true
  28. end.