Hi i want to find if string content this "|" this character.
example:-
$string = '$18,000 | new price'; 
if (preg_match('/[^|]/', $string)) {
}
else {
}
Hi i want to find if string content this "|" this character.
example:-
$string = '$18,000 | new price'; 
if (preg_match('/[^|]/', $string)) {
}
else {
}
 
    
    The pattern is wrong. No need of ^ in this case. Should be -
preg_match('/[|]/', $string);
You can use storpos - 
$string = '$18,000 | new price';
if(strpos($string, '|')) { ... }
 
    
    This should do the work.
$string = '$18,000 | new price'; 
if (strpos($string , '|') === false) {
     // Not found.
}
else {
    // Found.
}
