by
Roland Schumacher alias GENiALi
17. April 2008 -- 184
words -- 0 mal gelesen
The question was:
You are writing to application that processes phone numbers users have typed as strings. Would which of the following code samples 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) {
m match = regex.match (s, @ "^ \ (?))")} (\d{3})\)? [\s\-]? (\d{3})\-? (\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups [1], [2] m.Groups m.Groups [3]); " }
What is the difference? These are two answers. But we find
the difference. Who can find it? :-)
/ / C#
static string ReformatPhone
(string s) {
m match = regex.match (s, @ "^ \ (?))")} (\d{3})\)? [\s\-]? (\d{3})\-? (\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups [1], [2] m.Groups m.Groups [3]); " }
This reply should be correct.
/ / C#
static string ReformatPhone
(string s) {
m match = regex.match (s, @ "^ \ (?))")} (\d{3})\)? [\s\-]? (\d{3})\-? (\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups [1], [2] m.Groups m.Groups [3]); " }
49911851-4d32-4961-971c-00c735c5dad4|0|.0
Tags: