View Problem

Check if a string contains a match to a regular expression

Display "ok" if "abc 123 @#$" matches /\d+/
DiskEdit
python
found = re.search(r'\d+', 'abc 123 @#$')
if found:
print 'ok'
ExpandDiskEdit
erlang
% Erlang uses 'egrep'-compatible regular expressions, so shortcuts like '\d' not supported
String = "abc 123 @#$", Regexp = "[0-9]+",
is_match(String, Regexp) andalso (begin io:format("ok~n"), true end).
DiskEdit
erlang 12B3+
case re:run("abc 123 @#$", "\\d+") of {match, _} -> ok end.
ExpandDiskEdit
cpp C++/CLI .NET 2.0
if (Regex::IsMatch("abc 123 @#$", "\\d+")) Console::WriteLine("ok");

Submit a new solution for python, erlang, or cpp
There are 13 other solutions in additional languages (clojure, csharp, fantom, fsharp ...)