After WordPress 4.8 upgrade, wp_nav_menu() string search / replace not working

I found that WordPress added an extra space.

<ul  class="sub-menu"> 

so the search and replace could not be done correctly. If you look in the code inspector (developer tools) you won’t see the extra space. Once going to view source code (command + shift + U), I noticed the actual output code had the extra space. Hope this will help someone with similar problem.