- trim: documentation ( source)
- preg_replace: documentation ( source)
- json_encode: documentation ( source)
<?php
$myString=<<<TEXT
Found some changes in D:\EER Data\project\myfile.csv
TEXT;
$var1=trim(preg_replace("~[^a-z\d.:'\\\-]~i", ' ', $myString));
echo "$var1\n";
echo json_encode($var1); // it's a good idea to keep the escaping \ while in json.