Translated (deprecated) POSIX functions to PCRE, fixing #441

Fixes issue #441.

> **eregi()** was deprecated at PHP 5.3 in favor of the PCRE extension. The use of **eregi()** can cause warnings in some scenarios. 

Also added a cast to integer to be absolutely 100% sure the value is saved as an integer.