just worked for me to find if are 2 or more occurrence of a char, then by strlen them i found that exist 2 occurrence ex ( i dont use $matches at all):
$string = '1234|6|#red';
if(strlen(preg_match_all('/|/', $string,$matches, PREG_OFFSET_CAPTURE)) ==2){
echo 'i have 2 occurence of char: |';
}