C#
string resultString = Regex.Match(subjectString, @"\d+").Value;

string resultString = null;
try {
    resultString = Regex.Match(subjectString, @"\d+").Value;
} catch (ArgumentNullException ex) {
    // Wyraenie regularne ani acuch do przetworzenia nie mog mie wartoci null.
} catch (ArgumentException ex) {
    // W przekazanym wyraeniu regularnym wystpi bd skadniowy.
}

Regex regexObj = new Regex(@"\d+");
string resultString = regexObj.Match(subjectString).Value;

string resultString = null;
try {
    Regex regexObj = new Regex(@"\d+");
    try {
        resultString = regexObj.Match(subjectString).Value;
    } catch (ArgumentNullException ex) {
        // Wyraenie regularne ani acuch do przetworzenia nie mog mie wartoci null.
    }
} catch (ArgumentException ex) {
    // W przekazanym wyraeniu regularnym wystpi bd skadniowy.
}


VB.NET
Dim ResultString = Regex.Match(SubjectString, "\d+").Value

Dim ResultString As String = Nothing
Try
    ResultString = Regex.Match(SubjectString, "\d+").Value
Catch ex As ArgumentNullException
    'Wyraenie regularne ani acuch do przetworzenia nie mog mie wartoci null.
Catch ex As ArgumentException
    'W przekazanym wyraeniu regularnym wystpi bd skadniowy.
End Try

Dim RegexObj As New Regex("\d+")
Dim ResultString = RegexObj.Match(SubjectString).Value

Dim ResultString As String = Nothing
Try
    Dim RegexObj As New Regex("\d+")
    Try
        ResultString = RegexObj.Match(SubjectString).Value
    Catch ex As ArgumentNullException
        'Wyraenie regularne ani acuch do przetworzenia nie mog mie wartoci Nothing.
    End Try
Catch ex As ArgumentException
    'W przekazanym wyraeniu regularnym wystpi bd skadniowy.
End Try


Java
String resultString = null;
Pattern regex = Pattern.compile("\\d+");
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
    resultString = regexMatcher.group();
}

String resultString = null;
try {
    Pattern regex = Pattern.compile("\\d+");
    Matcher regexMatcher = regex.matcher(subjectString);
    if (regexMatcher.find()) {
        resultString = regexMatcher.group();
    }
} catch (PatternSyntaxException ex) {
    // W przekazanym wyraeniu regularnym wystpi bd skadniowy.
}


JavaScript
var result = subject.match(/\d+/);
if (result) {
    result = result[0];
} else {
    result = '';
}


PHP
if (preg_match('/\d+/', $subject, $groups)) {
    $result = $groups[0];
} else {
    $result = '';
}


Perl
if ($subject =~ m/\d+/) {
    $result = $&;
} else {
    $result = '';
}


Python
matchobj = re.search("wzorzec wyraenia regularnego", subject)
if matchobj:
    result = matchobj.group()
else:
    result = ""

reobj = re.compile("wzorzec wyraenia regularnego")
matchobj = reobj.search(subject)
if match:
    result = matchobj.group()
else:
    result = ""


Ruby
if subject =~ /wzorzec wyraenia regularnego/
    result = $&
else
    result = ""
end

matchobj = /wzorzec wyraenia regularnego/.match(subject)
if matchobj
    result = matchobj[0]
else
    result = ""
end
