Make sure you always enclose your code with [php] and [/php] tags. It's MUCH easier to read that way.
Your problem is probably this:
else ((preg_match("§esc_mon.esc\s([\S]*)§i", $str)) == true);
// should be:
else if (preg_match("§esc_mon.esc\s([\S]*)§i", $str));
FYI, preg_match returns either 0 (for no match found), or the number of matches found (always 1, since it stops after finding the first match). It does not return TRUE or FALSE.
It is true that 0 is equal to FALSE, and 1 is equal to TRUE. However, they are not identical, and it is not good coding practice to treat them the same. If a function returns a 0 or 1, then test for 0 or 1, don't test for TRUE or FALSE.
I will sometimes use a shortcut, like above, "if($condition) {" -- if $condition is TRUE, or any value above 1, the condition is satisfied. But if $condition returns a number, I never compare it to TRUE, because even though that would evaluate properly, they are not identical.
When testing for an actual TRUE or FALSE condition, use the Identical operator (===). Sometimes a function like strpos() will return 0 to indicate that it found the character at the beginning of the string. If you use the shortcut "if(!strpos($string, $needle)) {" it will incorrectly skip your code if your $needle is found at the beginning of string. Instead, use "if(strpos($string, $needle) === FALSE) {"