#1
|
|||
|
|||
Add dashes to each line of a list
Hello,
I have a list of IDs containing 32 characters and I need to format them in a certain way, namely to add dashes “-“ after the 8th, 12th, 16th, and 20th characters. So my question is: is there any way to format like this en masse because I obviously can’t add the dashes manually for the thousands of IDs I have. Here’s an example: Current ID -> 0DA88BE61C864A99BE730EEE81D82FCC Needed ID -> 0DA88BE6-1C86-4A99-BE73-0EEE81D82FCC I’d appreciate any help for this. Thanks, Tom |
#2
|
||||
|
||||
Use a replacement of:
([0-9A-Z]{8})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{12}) with \1-\2-\3-\4-\5 with the wildcard option set - http://www.gmayor.com/replace_using_wildcards.htm or by macro Code:
Sub Macro1() Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find Do While .Execute(FindText:="([0-9A-Z]{8})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{12})", _ MatchWildcards:=True, ReplaceWith:="\1-\2-\3-\4-\5") oRng.Collapse 0 Loop End With End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Worked like a charm!
Thanks, Graham. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search+replace all --- [3 dashes] with square wingding | imported_contiw | Word | 14 | 10-04-2017 01:03 PM |
Numbered list and one row table to appear on same line | jsukan | Word Tables | 1 | 04-09-2015 01:04 AM |
changing colons into dashes | retrofan | Word | 2 | 07-27-2014 05:05 AM |
letters are dashes | pmd | Word | 5 | 03-05-2012 08:08 PM |
Why word does not wrap on dashes? | lyrebird | Word | 3 | 06-23-2010 01:32 AM |