diff --git a/includes/command.inc b/includes/command.inc
index eae7de6..a1e1e9f 100644
--- a/includes/command.inc
+++ b/includes/command.inc
@@ -420,7 +420,7 @@ function _drush_find_commandfiles($phase) {
     // Scan for drush command files, load if found
     foreach (array_unique($searchpath) as $path) {
       if (is_dir($path)) {
-        $files = drush_scan_directory($path, '\.drush\.inc$');
+        $files = drush_scan_directory($path, '/\.drush\.inc$/');
         foreach ($files as $filename => $info) {
           require_once($filename);
           $list[basename($filename, '.drush.inc')] = $filename;
@@ -518,7 +518,7 @@ function drush_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $c
           // Give priority to files in this folder by merging them in after any subdirectory files.
           $files = array_merge(drush_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1), $files);
         }
-        elseif ($depth >= $min_depth && ereg($mask, $file)) {
+        elseif ($depth >= $min_depth && preg_match($mask, $file)) {
           // Always use this match over anything already set in $files with the same $$key.
           $filename = "$dir/$file";
           $basename = basename($file);
diff --git a/includes/drush.inc b/includes/drush.inc
index 0583a68..566b05b 100644
--- a/includes/drush.inc
+++ b/includes/drush.inc
@@ -769,14 +769,14 @@ function _drush_log_drupal_messages() {
           continue;
         }
         elseif (preg_match('/^warning:/i', $error)) {
-          drush_log(ereg_replace('/^warning: /i', '', $error), 'warning');
+          drush_log(preg_replace('/^warning: /i', '', $error), 'warning');
         }
         elseif (preg_match('/^notice:/i', $error)) {
-          drush_log(ereg_replace('/^notice: /i', '', $error), 'notice');
+          drush_log(preg_replace('/^notice: /i', '', $error), 'notice');
         }
         elseif (preg_match('/^user warning:/i', $error)) {
           // This is a special case. PHP logs sql errors as 'User Warnings', not errors.
-          drush_set_error('DRUSH_DRUPAL_ERROR_MESSAGE', ereg_replace('/^user warning: /i', '', $error));
+          drush_set_error('DRUSH_DRUPAL_ERROR_MESSAGE', preg_replace('/^user warning: /i', '', $error));
         }
         else {
           drush_set_error('DRUSH_DRUPAL_ERROR_MESSAGE', $error);
