Click here to Skip to main content
15,890,123 members
Home / Discussions / C#
   

C#

 
AnswerRe: Redirect to web page from windows form Pin
DaveAuld24-Mar-11 21:21
professionalDaveAuld24-Mar-11 21:21 
GeneralRe: Redirect to web page from windows form Pin
sarang_k24-Mar-11 21:28
sarang_k24-Mar-11 21:28 
QuestionIssue with Release Version Exe Pin
cancerion24-Mar-11 19:44
cancerion24-Mar-11 19:44 
QuestionRe: Issue with Release Version Exe Pin
DaveAuld24-Mar-11 21:19
professionalDaveAuld24-Mar-11 21:19 
AnswerRe: Issue with Release Version Exe Pin
Bernhard Hiller24-Mar-11 22:41
Bernhard Hiller24-Mar-11 22:41 
QuestionString format for MAC-address Pin
Mc_Topaz24-Mar-11 4:22
Mc_Topaz24-Mar-11 4:22 
AnswerRe: String format for MAC-address Pin
Luc Pattyn24-Mar-11 4:37
sitebuilderLuc Pattyn24-Mar-11 4:37 
AnswerRe: String format for MAC-address Pin
J4amieC24-Mar-11 5:38
J4amieC24-Mar-11 5:38 
You could do this with Regex.Replace[^].

The following regex will match your input (note the capture groups, will be used in the replacement):

^([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$


Next use a replacement string to put a hyphen between each of the 6 capture groups:

$1-$2-$3-$4-$5-$6


Final code which should work:

string mac1 = "00204A846187";
string pattern = "^([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$";
string replacemant = "$1-$2-$3-$4-$5-$6";
string mac2 = Regex.Replace(mac1,pattern,replacement);

AnswerRe: String format for MAC-address Pin
Richard MacCutchan24-Mar-11 5:53
mveRichard MacCutchan24-Mar-11 5:53 
AnswerRe: String format for MAC-address PinPopular
musefan24-Mar-11 6:56
musefan24-Mar-11 6:56 
AnswerRe: String format for MAC-address Pin
Ennis Ray Lynch, Jr.24-Mar-11 7:54
Ennis Ray Lynch, Jr.24-Mar-11 7:54 
AnswerRe: String format for MAC-address PinPopular
#realJSOP24-Mar-11 9:31
mve#realJSOP24-Mar-11 9:31 
AnswerRe: String format for MAC-address PinPopular
#realJSOP24-Mar-11 9:58
mve#realJSOP24-Mar-11 9:58 
GeneralRe: String format for MAC-address Pin
HimanshuJoshi24-Mar-11 10:04
HimanshuJoshi24-Mar-11 10:04 
GeneralRe: String format for MAC-address Pin
fjdiewornncalwe25-Mar-11 2:55
professionalfjdiewornncalwe25-Mar-11 2:55 
QuestionControl forms of an app Pin
dj_jeff24-Mar-11 3:43
dj_jeff24-Mar-11 3:43 
AnswerRe: Control forms of an app Pin
BobJanova24-Mar-11 5:23
BobJanova24-Mar-11 5:23 
AnswerRe: Control forms of an app Pin
Nitheesh George24-Mar-11 20:30
Nitheesh George24-Mar-11 20:30 
GeneralRe: Control forms of an app Pin
dj_jeff24-Mar-11 21:28
dj_jeff24-Mar-11 21:28 
GeneralRe: Control forms of an app Pin
Nitheesh George24-Mar-11 22:45
Nitheesh George24-Mar-11 22:45 
GeneralRe: Control forms of an app Pin
dj_jeff25-Mar-11 0:11
dj_jeff25-Mar-11 0:11 
QuestionDatagridviewcomboboxcolumn SelectedIndexChanged not work properly Pin
Davey_guan24-Mar-11 3:34
Davey_guan24-Mar-11 3:34 
AnswerRe: Datagridviewcomboboxcolumn SelectedIndexChanged not work properly Pin
Henry Minute24-Mar-11 17:12
Henry Minute24-Mar-11 17:12 
GeneralRe: Datagridviewcomboboxcolumn SelectedIndexChanged not work properly Pin
Davey_guan25-Mar-11 19:48
Davey_guan25-Mar-11 19:48 
GeneralRe: Datagridviewcomboboxcolumn SelectedIndexChanged not work properly Pin
Henry Minute26-Mar-11 5:03
Henry Minute26-Mar-11 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.