Hello Jonas,

That did not remove the first period|dot character as intended.

Please refine it further:-)

BTW, that TP-Link Router we were talking about now works with Orange ZTE dongle. We got new firmware from the manufacturer today.


On Thu, Nov 4, 2010 at 2:39 PM, Jonas | Lamu Software <jonas@lamusoftware.com> wrote:
preg_replace('/^webmail|gw|mail|otherstring\./i','', $vdomain);

before the regex ends here - |^(webmail| -as you are using pipe as a delimiter for the whole regex
you shouldn't need parenthesis as this is used for capturing and you are only replacing

(not tested)



On 11/04/2010 01:00 PM, Odhiambo Washington wrote:

Hello world,

I am looking at a certain function in php, from the IMP mail reader
(Horde Groupware). I have played a bit with it, but I hate the idea of
having several lines of:

 $vdomain = preg_replace('|^STRING\.|i', '', $vdomain);


<CUT>

if (!function_exists('_imp_hook_vinfo')) {
    function _imp_hook_vinfo($type = 'username')
    {
        $vdomain = getenv('HTTP_HOST');
        $vdomain = preg_replace('|^webmail\.|i', '', $vdomain);
        $vdomain = preg_replace('|^gw\.|i', '', $vdomain);
        $vdomain = preg_replace('|^mail\.|i', '', $vdomain);
        $vdomain =
preg_replace('|^(webmail|gw|mail|otherstring)\.|i','', $vdomain);
        $vdomain = String::lower($vdomain);

        if ($type == 'username') {
             return preg_replace('|\.|', '.', $_SESSION['imp']['user']
. '@' . $vdomain);
        } elseif ($type == 'vdomain') {
            return $vdomain;
        } else {
            return PEAR::raiseError('invalid type: ' . $type);
        }
    }
}
</CUT>

Now, instead of having several lines to match and replace a certain
string with an empty string, I am thinking a single line regex would do,
and it should, no??
I have tried the following:

$vdomain = preg_replace('|^(webmail|gw|mail|otherstring)\.|i','', $vdomain);


But I end up with an error: Unknown modifier 'g' in *hooks.php.*

Is it because I am using mixed up string separator?
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke



--
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254733744121/+254722743223
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Damn!!