<?php $str = 'abc | xx ?? "1 x \' 3" d e f \' y " 5 \' x yz'; echo preg_replace('~(?<!\\\\)(?:\\\\{2})*(?:"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\')(*SKIP)(?!)|\s+~s', '', $str);
You have javascript disabled. You will not be able to edit any code.