You need to amend your regular expression with a negative look-behind in the Unix case, so that it is not accidentally matched. Or just not use a regular expression at all. (substr is a better hammer for this kind of nail.)
Comment on Re: How to Detect Mixed File Line-Endings