I want a regex that can validate RegX to ensure no white space/escape characters can be used, especially CR
and LF
.
Any help would be appreciated.
If you use something like below, it will strip white spaces from a string.
$stripped_string = preg_replace("/[\s]/", "", $string);
Regex is not needed here. Just use method strpos()
, here's reference.
And use it to see, if there are any invalid characters rpesent:
$needles = array("
", "", "\t", " ", ...);
foreach($needles as $needle) {
$res = strpos($haystack, $needle, $offset);
if ($res !== false) ...do something
}