Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:47:48+00:00 2026-06-13T22:47:48+00:00

Hello I am trying to use TCL in a program called Shorthand which is

  • 0

Hello I am trying to use TCL in a program called Shorthand which is a text macro program.
Anyway I am trying to use it to stip and reformat Mac Addresses. I can not figure out the function to split a string at a specified index integer. Here is what I have so far.

set DirtyMac [sh_set clipboard]
set HalfMac [string map { .  "" } $DirtyMac ]
set FullMac [string map { : "" } $HalfMac]
set ParsedMac [string map { " " "" } $FullMac]
if {[string length $ParsedMac] < 12 } {
return "Mac too short";
} elseif {[string length $ParsedMac] > 12 } {
return "Mac too long";
} else {
return [string map { " " "" } $ParsedMac]
}

That is to clean the Mac of all unwanted characters
I have been trying

set Mac1 [linsert $ParsedMac 4 .]
return $Mac1;

or

set Mac1 [split [string is index $ParsedMac 4 ] "."]
return $Mac1;

Nothing is working… anything anyone can do to help would be great!

Ok so what I am trying to do is take a Mac address such as 11:22:33:44:55:66 or 1122.3344.5566 or 112233445566 and have the output be in one of the those 3 formats. I will ultimately write 3 different scripts that will be called based on the need of the output.

So for example
I have the mac 1122.3344.5566 I want to turn it into 11:22:33:44:55:66

set DirtyMac "1122.3344.5566"
set ParsedMac [string map {. "" : "" " " ""} $DirtyMac]
scan $ParsedMac "%2s%2s%2s%2s%2s%2s" a b c d e f
set FullMac [join $a $b $c $d $e $f  ":"]
return $FullMac;

OR

I have the mac 112233445566 I want to turn it into 1122.3344.5566

set DirtyMac "112233445566"
set ParsedMac [string map {. "" : "" " " ""} $DirtyMac]
scan $ParsedMac "%2s%2s%2s%2s%2s%2s" a b c d e f
set FullMac [join $a $b $c $d $e $f  ":"]
return $FullMac;

lastly

I have the mac 1122.3344.5566 || 11:22:33:44:55:66 I want to turn it into 112233445566

set DirtyMac | Mac Address Input|
set ParsedMac [string map {. "" : "" " " ""} $DirtyMac] 
return $ParsedMac;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:47:49+00:00Added an answer on June 13, 2026 at 10:47 pm

    First off, you can do the cleaning as a single step:

    set ParsedMac [string map {. "" : "" " " ""} $DirtyMac]
    

    Mind you, I’d actually be tempted to use a different cleaning method: removing all non-hex characters:

    set ParsedMac [regsub -all {[^0-9a-fA-F]} $DirtyMac ""]
    

    Secondly, splitting that string into 4-character pieces (note that I’m assuming you put the length checks in first) is actually best done with scan:

    scan $ParsedMac "%4x%4x%4x" a b c
    

    This extracts the four four-hex-digit characters and converts them into numbers. Alternatively, you can scan them as ordinary strings:

    scan $ParsedMac "%4s%4s%4s" a b c
    

    Then you’d need to do whatever you are looking to do with putting the pieces back together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am trying to use regular expressions in a java program. I would
Hello i'm trying to use autocomplete dropdownlist plugin that name is ufd. Anyway, I
Hello: Just a quick question.. I hope. I am trying to use this program
Hello I'm trying to use Three20 with my Monotouch Application with no luck. I
Hello I am trying to use the SimpleDateFormatter to parse the date Wed, 30
Hello I am trying to use a NSPopUpButtonCell inside an NSTableView. Basically when you
Im trying to use the string::find method to determine if the string hello (with
Hello Stackoverflowers, I'm trying to use a button, that first goes to another excel
I'm trying to use a ListView which is just like on this page: http://developer.android.com/resources/tutorials/views/hello-listview.html
I'm trying to use Qt Creator, but it is not working. My hello world

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.