Mac Textmate Regex 101 - clean blank lines


macrumors 6502
Original poster
I am trying to clean in Textmate some articles I downloaded from Factiva, before I send them to my Sony Reader. I created a command in the Bundle Editor to remove blank lines:

sed /^$/d

It works, but now I want to add a new twist and remove blank lines, as well as lines that contain a single space. I tried the following but it does not work:

sed /^$/d
sed /^\s$/d

Any idea?


macrumors 603
Jan 6, 2004
Western US
i don't think sed understands the backslash s. Try using an actual space or use [[:space:]].
Yep, this does work:

sed /^[[:space:]]$/d
The key is you do need to use double brackets. This isn't really clear from the TextMate manual. This will not work:

sed /^[:space:]$/d
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.