Tapatalk

How to remove line numbers and space from the beginning of all lines of a file?

How to remove line numbers and space from the beginning of all lines of a file?

3

PostFeb 17, 2022#1

Hello,

I'm trying to create a script or macro to search each line as far as the first space character, select all text before and including the space and delete it. Here's some sample text, I want to remove all the numerical values from the beginning of each line. You can see there is a line between lines 9 and 10 staring with a Q which should not be affected. The format of the file is always the line number, space, then the content of the line.

Code: Select all

1 BEGIN PGM Model_0 MM
2 ; 07.01.2022   14:53
3 BLK FORM 0.1 Z X-75 Y-25 Z199.75
4 BLK FORM 0.2 X75 Y25 Z250.5
5 ; --- files_x\StartEnd\pgm_bgn.txt ---
6 FN 17: SYSWRITE ID 507 NR0 IDX1.0 =+0
7 FN 17: SYSWRITE ID 507 NR0 IDX2.0 =+0
8 FN 17: SYSWRITE ID 507 NR0 IDX3.0 =+0
9 CYCL DEF 247 PRESETTING ~
 Q339=+0    ;PRESET NUMBER
10 ; -------------------------------------
11 ;
12 ; --- files_x\StartEnd\pgm_bgn_2.txt ---

.
.
96 L X-81.327 Y-23.735 Z240.103
97 L X-81.676 Y-23.713 Z240.134
98 L X-81.868 Y-23.746 Z240.151 F50000
99 L X-82.042 Y-23.835 Z240.168
100 L X-82.182 Y-23.972 Z240.185
101 L X-82.276 Y-24.143 Z240.202
102 L X-82.314 Y-24.335 Z240.219
103 L X-82.294 Y-24.529 Z240.237
104 L X-82.217 Y-24.709 Z240.25
I was working with this but it keeps searching every line for every space character, I couldn't get it to stop after the first one.

Code: Select all

InsertMode
ColumnModeOn
HexOff
UltraEditReOn
Find " "
IfFound
DeleteToStartofLine
MoveLineDown

6,825625
Grand MasterGrand Master
6,825625

PostFeb 18, 2022#2

The macro code for removal of line numbers at beginning of all lines using an UltraEdit regular expression replace all is:

Code: Select all

InsertMode
ColumnModeOff
HexOff
Top
UltraEditReOn
Find MatchCase RegExp "%[0-9]+ +"
Replace All ""
The plus after the space character can be removed to delete just the first space together with the line number.