Does anyone have any ideas how to do this automatically?
A "simple" regular expression replace can do it:
In UltraEdit style:
Find What: %^(*^p^)*^p
Replace With: ^1
In Unix/Perl style:
Find What: ^(.*\p).*\p
Replace With: \1
Because of ^p or \p this works only for files with DOS line terminations (CR+LF). See in help of UE/UES the pages Find command or Replace command and Regular Expressions to understand it.
In UltraEdit style:
Find What: %^(*^p^)*^p
Replace With: ^1
In Unix/Perl style:
Find What: ^(.*\p).*\p
Replace With: \1
Because of ^p or \p this works only for files with DOS line terminations (CR+LF). See in help of UE/UES the pages Find command or Replace command and Regular Expressions to understand it.
Best regards from an UC/UE/UES for Windows user from Austria
Thanks, works perfectly, expect that the last line doesn't remove but it's easy to remove.
How about:
How about:
- Remove every last/first line?
- Remove every third line?
- Duplicate every line?
The last line should always have a crlf to work properly.
1.: Use "TOP", "BOTTOM" and "DELETELINE" in an UE macro to do this job.
2.: Also a UE macro with key arrow down + deleteline + "EOF loop". Easy.
3.: Also a trivial UE macro with arrow down and duplicateline.
Bego
1.: Use "TOP", "BOTTOM" and "DELETELINE" in an UE macro to do this job.
2.: Also a UE macro with key arrow down + deleteline + "EOF loop". Easy.
3.: Also a trivial UE macro with arrow down and duplicateline.
Bego
Normally using all newest english version incl. each hotfix. Win 10 64 bit
Thanks, Bego. But I don't get any of your advice working. :?
Is it possible to do these with the 'regular expression' feature?
Is it possible to do these with the 'regular expression' feature?
No. regexps are good for "inLINE-searching/replacing", not for navigating in a file.
Try this:
Create a macro called "delTopBottom"
Paste in those lines:
Let it run on your example file. It should do your issue no. 1
rds Bego
Try this:
Create a macro called "delTopBottom"
Paste in those lines:
Code: Select all
HexOff
Top
DeleteLine
Bottom
DeleteLine
rds Bego
Normally using all newest english version incl. each hotfix. Win 10 64 bit
Thanks once again, Bego. But it's not even works now.
I figured out these which can do only at the top of the document also 'Play macro to End of File' have to use:
1. Remove every last/first line
2. Remove every third line
3. Duplicate every line (does not works - does not duplicate first line and the macro loops infinitely )
I figured out these which can do only at the top of the document also 'Play macro to End of File' have to use:
1. Remove every last/first line
Code: Select all
HexOff
Key DOWN ARROW
DeleteLine
Code: Select all
HexOff
Key DOWN ARROW
Key DOWN ARROW
DeleteLine
Code: Select all
HexOff
Key DOWN ARROW
DupeLine
How to delete every second line in a text file?
It's a small macro that is supposed to delete every second line in a file but stalls in the beginning.
What have I missed?
Code: Select all
InsertMode
ColumnModeOff
HexOff
Top
Loop 0
MoveLineDown
MoveLineDown
DeleteLine
ExitLoop
EndLoop
Top
Re: How to delete every second line in a text file?
The command MoveLineDown does not only move the cursor down, it moves the entire line down. And you exit your endless loop after deleting 1 line because ExitLoop is inside the loop without any condition.
You don't really need a macro for that job because a single regular expression replace can do that too. However, here is the macro.
InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
IfColNumGt 1
"
"
IfColNumGt 1
DeleteToStartofLine
EndIf
EndIf
Top
Find RegExp "%^(*^r++^n^)*^r++^n"
Replace All "^1"
This macro should work for files with DOS or UNIX line terminations, but definitely not for MAC files.
You don't really need a macro for that job because a single regular expression replace can do that too. However, here is the macro.
InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
IfColNumGt 1
"
"
IfColNumGt 1
DeleteToStartofLine
EndIf
EndIf
Top
Find RegExp "%^(*^r++^n^)*^r++^n"
Replace All "^1"
This macro should work for files with DOS or UNIX line terminations, but definitely not for MAC files.
Best regards from an UC/UE/UES for Windows user from Austria