THE BOOK cover
The Unwritten Book is Finally Written!
An in-depth analysis of: The sacrifice bunt, batter/pitcher matchups, the intentional base on balls, optimizing a batting lineup, hot and cold streaks, clutch performance, platooning strategies, and much more.
Read Excerpts & Customer Reviews

Buy The Book from Amazon


SABR101 required reading if you enter this site. Check out the Sabermetric Wiki. And interesting baseball books.
MOST RECENT ARTICLES
MAIL : You ask | We say

Advanced


THE BOOK--Playing The Percentages In Baseball

<< Back to main

Friday, August 06, 2010

CRLF Hack

By Tangotiger, 10:24 AM

This is purely for those people who cut/paste things from emails and the like (where a forced hard-return is set after each line) and want to convert it so that that hard-return is removed.  This is what I do:

1. find/replace all DOUBLE hard-returns with a weird character (I use ~~~).  In my editor, EditPlus, that means setting regular expression on, and replacing \n\n with ~~~. 

2. find/replace all SINGLE hard-returns with a space.  That means \n becomes _ (where _ is really you hitting the spacebar once). Your whole document is now on one line.

3. find/replace all DOUBLE spaced with a single space.  (Just in case step 2 added a space you didn’t want.)

4. find/replace ~~~ with DOUBLE hard-returns (to undo the damage of Step 1).

I figure there’s someone else out there that’s been bothered by this, and who ends up taking care of it manually.  Now you have it a different way.


Web Admin
#1    Ken Arneson      (see all posts) 2010/08/06 (Fri) @ 11:23

This is a UNIX thing, but here’s how I do it.

Save to a file, then open the file in the vi editor, like so:

vi filename

Then type this in the editor:

:%s/^V^M//g

Where the ^V is Cntl-V and the ^M is Cntl-M

Then type
:w

to save the file.  Done.


#2    Ben V-L      (see all posts) 2010/08/06 (Fri) @ 12:40

Perl, from unix prompt:

# remove hard return
perl -p -e ‘s/\r$//’ < windows.txt > unix.txt

# add it back
perl -p -e ‘s/\n/\r\n/’ < unix.txt > windows.txt


#3    SirKodiak      (see all posts) 2010/08/06 (Fri) @ 17:55

Notepad++ has a very good search and replace feature that handles both regexp and extended (/n, /t, etc). 

http://notepad-plus-plus.org/


Page 1 of 1 pages


Name (required)
E-Mail (optional; WILL be published)
Website (optional)

<< Back to main


Latest...

COMMENTS

May 25 05:00
Help needed with sticky issue…

May 25 04:38
The first time a pitcher has ever intentionally thrown at a batter….

May 25 03:39
Lack of hustle during a game

May 25 02:54
Largest demonstration in Canadian history?

May 25 02:38
NFLPA lawsuit against collusion

May 25 01:43
Neal Huntington’s best moves

May 24 23:50
Rooting for laundry

May 24 17:04
Firefox, IE, or Chrome?

May 24 12:07
How to beat the shift

May 24 11:11
Incredible story