|
|
Use perl to repair a mis-formatted text file
perl -pe 's/(w)([.])(w)/$1$2 $3/g' source.txt > final.txt
First, two quick fixes:
The quick explanation:
So, roughly translating the original version (assuming the Match any "word" character, followed by a literal period, followed by any other "word" character, putting each of those characters into buffers 1, 2, and 3, respectively, and then replace those three characters with "the contents of buffer 1" + "the contents of buffer 2" + a space + "the contents of buffer 3".Or, even more loosely translated: Any time you see a "word" character followed by a period followed by a "word" character, stick a space after the period. The problem is that, as the example text shows, sometimes sentences can start/end with characters that aren't "word" characters, like quotation marks. So changing |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.10 seconds |
|