Feed
Google+
Contact
XING
LinkedIn
Twitter
ICQ
meebo.com

70-536 - Finde den Unterschied

by Roland Schumacher alias GENiALi 17. April 2008 -- 129 words  -- 2091 mal gelesen

Die Frage war:

You are writing an application that processes phone numbers users have typed as strings. Which of the following code samples would reformat any of the following inputs?

555-555-1111
(555) 555-1111
5555551111
555 555-1111

In the following code samples, the string input is passed to the method as s.

// C#
static string ReformatPhone(string s)
{
    Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$");
    return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);
}

Wo ist hier der Unterschied? Das sind zwei Antworten. Aber wir finden
den Unterschied nicht. Wer findet ihn? :-)

// C#
static string ReformatPhone(string s)
{
    Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$");
    return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);
}

Richtig soll diese Antwort sein.

// C#
static string ReformatPhone(string s)
{
    Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$");
    return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);
}

es läuft: Clawfinger – Zeros & Heroes – four letter word

Tags:

Ausbildung

Kommentar schreiben

  Country flag

biuquote
  • Kommentar
  • Live Vorschau
Loading

Statistik

Gesamte Posts: 1018
Dieses Jahr: 0
Diesen Monat: 0
Diese Woche: 0
Kommentare: 922
Total Bewertungen: 84
Ø Bewertung: 4,37
Meisten Kommentare
Google+ ... (28)
Beste Ø Bewertung
Tryton - Teil 6 - Installation ... (5)
Meiste Bewertungen
Windows 7 und die ersten Erfah ... (5)

Buttons

Benutzerprofil von GENiALi connection speed test network connection Bloggeramt.de Slug.ch Blog Verzeichnis und Blog Webkatalog Schumacher Roland Seitwert Valid XHTML 1.0 Transitional