This occurs when I open admin or front on localhost

What version of WordPress are you running? Can you perhaps include the code from line 252 of that file? If it’s a current installation of WordPress, then it’s this:

/**
 * @since 1.2.0
 */
if ( !defined('COOKIEPATH') )
  define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . "https://wordpress.stackexchange.com/" ) );

… And I can’t really see why that all of a sudden should fail. … So perhaps try and activate another theme, to see if it’s some buggy code in your current theme – or if it’s a corrupt WordPress installation.

In order to debug it, then you could (TEMPORARILY!!) change it to this, and reload a page and see what it outputs:

/**
 * @since 1.2.0
 */
if ( !defined('COOKIEPATH') ){
  echo '<pre>';
  print_r( get_option('home') );
  echo '</pre>';
  die();
  define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . "https://wordpress.stackexchange.com/" ) );
}

If you have access to the database, then you could also see in wp_options-table, what the value for option_name=home is. Maybe something or someone changed the home-name to something mysterical.

… Or since it’s a local installation, then it could be because of a space in the folder-name (in case that you changed the path for security’s sake)?