Question: I need to remove only the `LF`, not `CRLF`. Any idea about that? 

I can use PHP, notepad++, shell script, etc

![enter image description here](https://i.stack.imgur.com/0JUhH.png)

Answer: 
Use a negative lookbehind.

```
$str = preg_replace("#(?<!\r)\n#", '', $str);

```

[**Fiddle**](http://codepad.viper-7.com/Ty9XWn)
LF stands for line feed character, which is ASCII 10 or 0x0A or "\n" (in PHP). So just do 

`search_replace( "\n", '', $text)`

Pleae note CRLF are in fact two characters CR (carriage return) + LF. If you remove LF, you will still have CR (if any) in your text.

**EDIT**

If you want to remove just standalone LFs but keep CRLF then above code is wrong as it would turn CRLF into CRs. Use `preg_replace()` to do that

```
preg_replace("/(?<!\\r)\\n+(?!\\r)/", '', $text);

```

If for any reasons you'd like not to use `preg_replace()` (but do use it anyway), then you can try this dumb approach:

```
// save CRLFs by replacing with some text that does 
$tmp = str_replace("\r\n", 'S0m3L1k3LyUn1Qu3T3X7', $text);

// get rid of LFs
$tmp = str_replace("\n", '', $tmp );

// restore CRLFs
$text = str_replace('S0m3L1k3LyUn1Qu3T3X7', "\r\n", $tmp);

```