+ Reply to Thread
Results 1 to 3 of 3

REGEX to delete all non hex characters

  1. #1
    Registered User
    Join Date
    04-17-2012
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    2

    REGEX to delete all non hex characters

    I need to make a VBA script that will let me put in any MAC address (input formats listed below) and then put out one of several formats.

    I have been able to do most of the VBA so far but the only problem is that I can't get a regex pattern to match the dots, dashes, colons or other separators.

    This is the function that I am using to try to isolate the problem with the regex.

    Please Login or Register  to view this content.
    This function will take the text in string and remove only the first ":". I have tried to add an astrik to the end (e.g. (?:[^0-9a-fA-F])*) but that is actually causing it not to find any of the colons.

    Here are some examples of what I am getting now and what I would like to get with the function working correctly.

    Current Results
    00:11:22:33:44:55 - 0011:22:33:44:55

    Ideal Results
    00:11:22:33:44:55 - 001122334455
    00-11-22-33-44-55 - 001122334455
    00.11.22.33.44.55 - 001122334455
    0011.2233.4455 - 001122334455

    Thanks for all the help. Let me know if you have any questions!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: REGEX to delete all non hex characters

    Hello creeves95833,

    Welcome to t he Forum!
    Here is the corrected code...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-17-2012
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: REGEX to delete all non hex characters

    Thanks Leith Ross - That worked perfectly. Sadly it was far easier that I thought it would be, but glad it works now!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1