iMisspell
March 17th, 2010, 08:45 AM
I have files with a bunch of lines...
Small example...
(ANYTHING IN PARENTHESES DO NOT TOUCH)
(UNTOUCHED TEST!@#TEST1234TEST)
N007T04
N008G54.1P01
N009S1000M03
N010G00X3.97Y7.3
N011G43H02Z0.75
N012Z0.45
N013G1Z0.01F75.M08
N014Y0.F20.
N015G2X3.97Y0.I-3.97J0.F42.5
And i need to seperate the line by adding a space between 'letters' and 'numbers' and possibly a 'period' ...
(ANYTHING IN PARENTHESES DO NOT TOUCH)
(UNTOUCHED TEST!@#TEST1234TEST)
N007 T04
N008 G54.1 P01
N009 S1000 M03
N010 G00 X3.97 Y7.3
N011 G43 H02 Z0.75
N012 Z0.45
N013 G1 Z0.01 F75. M08
N014 Y0. F20.
N015 G2 X3.97 Y0. I-3.97 J0. F42.5
As you will see, im horrible with Regular Expressions, ive tried the following, which is close, but still not working correctly...
sed 's/\([0-9]*\)*\([A-Z]\)/\1 \2/g' $file
Will produce the following.
The first 'space' before N### can not be there, and the 'spaces' added with-in the parentheses are not wanted.
( A N Y T H I N G I N P A R E N T H E S E S D O N O T T O U C H)
( U N T O U C H E D T E S T!@# T E S T1234 T E S T)
N007 T04
N008 G54.1 P01
N009 S1000 M03
N010 G00 X3.97 Y7.3
N011 G43 H02 Z0.75
N012 Z0.45
N013 G1 Z0.01 F75. M08
N014 Y0. F20.
N015 G2 X3.97 Y0. I-3.97 J0. F42.5
Any help would be great.
_
Small example...
(ANYTHING IN PARENTHESES DO NOT TOUCH)
(UNTOUCHED TEST!@#TEST1234TEST)
N007T04
N008G54.1P01
N009S1000M03
N010G00X3.97Y7.3
N011G43H02Z0.75
N012Z0.45
N013G1Z0.01F75.M08
N014Y0.F20.
N015G2X3.97Y0.I-3.97J0.F42.5
And i need to seperate the line by adding a space between 'letters' and 'numbers' and possibly a 'period' ...
(ANYTHING IN PARENTHESES DO NOT TOUCH)
(UNTOUCHED TEST!@#TEST1234TEST)
N007 T04
N008 G54.1 P01
N009 S1000 M03
N010 G00 X3.97 Y7.3
N011 G43 H02 Z0.75
N012 Z0.45
N013 G1 Z0.01 F75. M08
N014 Y0. F20.
N015 G2 X3.97 Y0. I-3.97 J0. F42.5
As you will see, im horrible with Regular Expressions, ive tried the following, which is close, but still not working correctly...
sed 's/\([0-9]*\)*\([A-Z]\)/\1 \2/g' $file
Will produce the following.
The first 'space' before N### can not be there, and the 'spaces' added with-in the parentheses are not wanted.
( A N Y T H I N G I N P A R E N T H E S E S D O N O T T O U C H)
( U N T O U C H E D T E S T!@# T E S T1234 T E S T)
N007 T04
N008 G54.1 P01
N009 S1000 M03
N010 G00 X3.97 Y7.3
N011 G43 H02 Z0.75
N012 Z0.45
N013 G1 Z0.01 F75. M08
N014 Y0. F20.
N015 G2 X3.97 Y0. I-3.97 J0. F42.5
Any help would be great.
_