Fix #1150 (CoTemplate ruins source format)

* Enchanced regex to track source spaces and CR/LF
* Reworked for slightly better performance (avarage 10% faster)