Quick and dirty macro, surely not the best solution. The macro expands all values to 3 numbers by adding the missing leading zeros, sort it and removes the leadings zeros. Remove the red lines at the end of the macro, if you don't want to remove the added zeros. The file should contain only the IP addresses and every IP address should beginn at start of a line. The regexps are in UltraEdit style!
InsertMode
ColumnModeOff
HexOff
UnixReOff Bottom
IfColNum 1
Else
"
"
EndIf
Top
TrimTrailingSpaces
Find RegExp "%^([0-9]^)."
Replace All "00^1."
Top
Find RegExp "%^([0-9][0-9]^)."
Replace All "0^1."
Loop
Top
Find RegExp ".^([0-9]^)."
IfFound
Find RegExp ".^([0-9]^)."
Replace All ".00^1."
Else
ExitLoop
EndIf
EndLoop
Loop
Top
Find RegExp ".^([0-9][0-9]^)."
IfFound
Find RegExp ".^([0-9][0-9]^)."
Replace All ".0^1."
Else
ExitLoop
EndIf
EndLoop
Top
Find RegExp ".^([0-9]^)$"
Replace All ".00^1"
Top
Find RegExp ".^([0-9][0-9]^)$"
Replace All ".0^1"
SortAsc IgnoreCase RemoveDup 1 -1 0 0 0 0 0 0 Top
Find RegExp "0^([0-9][0-9]^)"
Replace All "^1"
Top
Find RegExp "0^([0-9]^)"
Replace All "^1"
Best regards from an UC/UE/UES for Windows user from Austria
Mofi wrote:Quick and dirty macro, surely not the best solution. The macro expands all values to 3 numbers by adding the missing leading zeros, sort it and removes the leadings zeros. Remove the red lines at the end of the macro, if you don't want to remove the added zeros. The file should contain only the IP addresses and every IP address should beginn at start of a line. The regexps are in UltraEdit style!
Doesn't seem to work.
Do I need to select the lines beginning with an IP ?
I get an error..
"Search string not found!"
It seems to fail at line 7..
Find RegExp "%^([0-9]^)."
UE needs a MACRO debugger or at the very least a way to step thru
the macro one line at a time...
The macro is written for a file which only contains IP addresses at beginning of the line. So copy the addresses temporarily to a new file. No need to save the new file. And you have to check the macro option Continue if a Find with Replace not found at the macro properties.
For "debugging" simply insert the ExitMacro command, where the macro should stop so you can look the result of the macro execution til this point. Use "Revert to Saved" from File menu to undo all changes, edit the macro to move the ExitMacro to a new position or delete it and run macro again.
Sometimes it is even better to insert following commands, where you want to pause the execution of the macro:
GetString "Break 1"
Key BACKSPACE
Now the macro shows a dialog, where the user can enter a string, which is inserted into the file. When the dialog is opened, look at your file, then enter a single character (1 space for example) and press OK. The inserted single character is immediately deleted with backspace and the macro continues until next GetString command. "Break 1" is a text, which is displayed above the enter field, so you can define different "break points".
This "pause" method can be expanded with following commands:
GetString "Break 1"
Key LEFT ARROW
IfCharIs "1"
Key DEL
ExitMacro
Else
Key DEL
EndIf
This gives you the possibilitiy to stop macro execution, when you enter only the character '1' as string in the GetString dialog, all other entered single characters continue macro execution.
Best regards from an UC/UE/UES for Windows user from Austria
Although 23.35.30.138 is not at your list, I have found the problem. I guess 23.35.30.138 was the last IP address and this last line was not terminated with a valid line ending (CRLF for DOS or LF for Unix).
I have added the green marked macro code, which adds a line termination on last line of the file, if it is not already present. Then the sort works with only one run.
Note: If you normally work with Unix regular expressions, add UnixReOn as last command to the macro code or this macro will also turn off your prefered setting of Unix style Regular Expressions at Advanced - Configuration - Find.
Best regards from an UC/UE/UES for Windows user from Austria