• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Edit text file. Remove varying end of each line.

n666

Senior member
Hey All,

I'm working with a large document in which I need to get rid of some junk at the end of each line of text.

For example:

Concerts - Alan Jackson 2006/11/07 22:17:07
Concerts - Anthrax 2007/02/13 22:01:18 2007/02/13 22:01:18

Needs to become:

Concerts - Alan Jackson
Concerts - Anthrax


something Java based would be best.

Thanks
 
Will each line follow the EXACT same formatting for the start? IE... Will it always be "Concerts - Performer Name" followed by the junk? Will the data following the name always be a date/time as well?
 
using java I would use regular expression, go line by line and do something like this:

(it looks for the beginning of the date with a pattern like "####/" )

edit: i have no idea why the code thing is bunching up my lines like that
 
Java? Seems awfully excessive for something like this. How about sed?

sed -i 's/ [^a-zA-Z]*$/' filename.txt

That will get rid of all non-alphabetic characters at the end of a line (that follow a space, so a song ending in a number won't be affected).
 
Back
Top