A sample values like this:
fdsfsf345#3gt#$%3^#$T$#tr43r43
test spaces
"test spaces"
"fdsfsf345#3gt#$%3^#$T$#tr43r43" #comment
"test spaces" #comment
A script:
$re = '/(.*)(?:\"|\'|)(?: )#?(.*)|(.*)/mi';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches);
A problem is that a line without '# comment' prints
A result should be on first array:
fdsfsf345#3gt#$%3^#$T$#tr43r43
test spaces
"test spaces"
"fdsfsf345#3gt#$%3^#$T$#tr43r43"
"test spaces"