Reformat MAC Address with Replace/Regular Expressions

Find, replace, find in files, replace in files, regular expressions

Reformat MAC Address with Replace/Regular Expressions

Postby Davis » Thu Feb 24, 2005 6:27 pm

I am trying to reformat MAC addresses from the output of another file. The current format is nn-nn-nn-nn-nn-nn and I would like the output to be nnnn.nnnn.nnnn. In this case n is 0-9 or a-f. An example may help.
OLD Format _______ New Format
00-02-e3-08-f7-d2 0002.e308.f7d2
00-0a-5e-45-98-f2 000a.5e45.98f2
00-02-e3-06-87-44 0002.e306.8744

Thank You Very Much in Advance. I do appreciate it!

~Davis
Don't get stuck on "it should work".
Look for what works well.
User avatar
Davis
Newbie
 
Posts: 2
Joined: Thu Feb 24, 2005 12:00 am

Re: Reformat MAC Address with Replace/Regular Expressions

Postby mrainey56 » Thu Feb 24, 2005 7:52 pm

Find What: ([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])

Replace With: \1\2.\3\4.\5\6


Regular Expressions must be checked in the Replace dialog

Unix style regular expressions checked
main menu Advanced > Configuration > Find
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Reformat MAC Address with Replace/Regular Expressions

Postby Davis » Fri Feb 25, 2005 12:09 am

Awesome, And I mean You!! :D

Thank You Very Much! I had started along the right path but would have never figured out the menu settings. Another mistake I made was that I was using [1-9a-z][1-9a-z]- for the search string. (No wonder it didn't work. But I tried many variations before I posted)

Your answer says tons and will act as a guide for other challenges where I anticipate the need to do replaces.

Thank You Very Much!!!!
User avatar
Davis
Newbie
 
Posts: 2
Joined: Thu Feb 24, 2005 12:00 am

Re: Reformat MAC Address with Replace/Regular Expressions

Postby Klaatu » Tue Mar 01, 2005 1:27 pm

mrainey56 wrote:Find What: ([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])-([0-9,a-z][0-9,a-z])

Replace With: \1\2.\3\4.\5\6


I'm looking at UltraEdit's help, and from reading it it looks to me like what you have above, "[0-9,a-z]" would not only match more than he was asking for, but would also match a comma. I see no mention of having to separate ranges by commas.

Is this an indication of how poor UltraEdit's help is when it comes to documenting the Unix style regular expressions it supports, or is it me?

I was also trying to find out if UltraEdit supported the unix-style non-greedy syntax of "*?", but could find nothing on it. Not even on a search of this forum.
User avatar
Klaatu
Newbie
 
Posts: 5
Joined: Thu Feb 24, 2005 12:00 am
Location: Ceti-Alpha 5

Re: Reformat MAC Address with Replace/Regular Expressions

Postby mrainey56 » Tue Mar 01, 2005 1:42 pm

You're correct, comma not needed. Don't know where I picked that up.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina


Return to Find/Replace/Regular Expressions