Login
|
Signup
langref.org
-
ruby
,
csharp
,
cpp
,
clojure
...
add..
all
erlang
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Regex
Searching
Check if a string contains a match to a regular expression
Display
"ok"
if
"abc 123 @#$"
matches
/\d+/
ruby
puts "ok" if (text=~/\d+/)
text = "abc 123 @#$"
puts "ok" if (text=~/\d+/)
csharp
if(System.Text.RegularExpressions.Regex.IsMatch("abc 123 @#$",@"\d+")){
Console.WriteLine("ok");
}
if(System.Text.RegularExpressions.Regex.IsMatch("abc 123 @#$",@"\d+")){
Console.WriteLine("ok");
}
cpp
C++/CLI .NET 2.0
if (Regex::IsMatch("abc 123 @#$", "\\d+")) Console::WriteLine("ok");
using namespace System;
using namespace System::Text::RegularExpressions;
int main()
{
if (Regex::IsMatch("abc 123 @#$", "\\d+")) Console::WriteLine("ok");
}
clojure
(if (re-find #"\d+" "abc 123 @#$")
(println "ok"))
(if (re-find #"\d+" "abc 123 @#$")
(println "ok"))
fantom
m := Regex<|\d+|>.matcher("abc 123 @#\$")
if (m.find)
echo("ok")
class SolutionXX
{
Void main()
{
m := Regex<|\d+|>.matcher("abc 123 @#\$")
if (m.find)
echo("ok")
}
}
Submit a new solution for
ruby
,
csharp
,
cpp
,
clojure
...
There are 12 other solutions in
additional
languages (
erlang
,
fsharp
,
groovy
,
haskell
...)