How should I configure the trusted hosts setting? I am trying to add the Trusted Host setting. I copied the code directly from the settings.php file, making sure I removed the * and changed the example to my domain.  Using the first example

$settings['trusted_host_patterns'] = array(
  '^www\.example\.org$',
);


The site would not load....got an error stating domain was disallowed

Today using this code
and

$settings['trusted_host_patterns'] = array(
  '^example\.org$',
  '^.+\.example\.org$',  
);


I am getting an unexpected error and the site won't load

This is a new site on a shared host.  It can't be this difficult!  I must be missing something!
I don't know if I was introducing a problem by editing the settings.php off line and then uploading it but decided to edit it with the editor in the file manager on cpanel.  I first changed the permissions on the default folder to 755 and opened the folder.  Then I highlighted the settings file and changed the permissions to 755.  Then I clicked the edit button and located the Trusted Host settings and copied the code.  I then pasted it AT THE END of the settings.php file and made the necessary changes to reflect my domain and saved the file and closed the setting file.  In a different window, I had the website status page loaded and just refreshed it.  IT worked!  I don't know why doing it this way worked (editing the file on the server vs offline and uploading it.) but it did! Then I just change the file permissions back to what they were .