Page 1 of 1
Delete all characters after line "x" in every row
Posted: Tue Feb 10, 2009 5:43 pm
by the_egg_man
I have a file with two side by side groups of data and I want to remove everything in the second group. Something like this:
Code: Select all
Group A Group B
Rounding Report
Admission Report Patient Snapshot Report
MD Overview Report
Kardex Report Dept Orders Report
Maternal Assess Report
In the actual file Group B begins at column 77. In every row I want to delete everything beyond column 77.
Thanks,
Andrew
Posted: Tue Feb 10, 2009 7:00 pm
by Bob Hansen
This will work to remove all characters after position 76
Search for: ^(.{76}).*
Replace with: \1
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Posted: Tue Feb 10, 2009 7:00 pm
by talleyrand
Search for: (^.{77}).*
Replace with : \1
Assumes posix regular expressions checked.
Might check that I'm not off by one on that 77
Posted: Tue Feb 10, 2009 7:01 pm
by talleyrand
Looks like I was, that's why we keep Bob around

Posted: Tue Feb 10, 2009 7:04 pm
by Bob Hansen
Not sure I am right.
After looking at yours, and rereading the original request, he does ask to remove everything after 77. You took that literally, I thought something else was wanted ...... and should have been more careful in reading what was asked for.
Thanks
Posted: Tue Feb 10, 2009 7:30 pm
by the_egg_man
Thank you both. Yes, I wasn't terribly clear but the exact column position wasn't as important to me as syntax. This gives me just what I needed. Much appreciated. - Andrew