Page 1 of 1
Search and replace: inserting colons in multiple lists?
Posted: Tue Apr 11, 2023 10:23 am
by daniel.337
Hi there,
I have a huge amount of lists with documentated MAC addresses.
Unfortunately many of these entries are written down in the following format:
To get a better readable and viewable style of the MAC addresses I would like to change all of this entries automatically to this format, inserting colons between each hexadecimal octet:
Is it possible to this automatic insertion via the function "Search and Replace" in TextPad? This would be great.
Regards,
Daniel
Re: Search and replace: inserting colons in multiple lists?
Posted: Tue Apr 11, 2023 12:39 pm
by ben_josephs
Search | Replace... (
<F8>):
Find what: ([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})
Replace with: $1:$2:$3:$4:$5:$6
[X] Regular expression
Replace All
You can save that as a macro.
Re: Search and replace: inserting colons in multiple lists?
Posted: Tue Apr 11, 2023 1:38 pm
by daniel.337
Wow, great, this is what I was searching for.
Thank you very much!
Daniel
Re: Search and replace: inserting colons in multiple lists?
Posted: Tue Apr 11, 2023 1:40 pm
by AmigoJack
Yes:
- Open all "lists" (I suppose files) in TextPad. Of course: start with 2-5 for testing all this first.
- Press F8 or select Search > Replace... to get that dialog.
- Tick Conditions > Regular expressions since you want to match a pattern instead of exact texts.
- Tick Conditions > Match case in case the letters are really all uppercase - this reduces matching false positives.
- Tick Scope > All documents to perform this on all opened files.
- Find what:
Code: Select all
([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})
- Replace with:
- Click Replace All.
- Close dialog.
- Press Ctrl+Shift+S or select File > Save all to store all modifications to the open files.
However, if your list format is more distinctive (f.e. the MAC addresses always appear on their own line, or always from position 12 to 24, or always come with this or that prefix), then the regex can be more specific, really only matching what you want. By now it would also match the word DEADCAFEBABE or numbers like 017588439425.