Yes I basically wanted to prevent bolded/linked tags from appearing within other attributes like titles, alt, src, hrefs etc so I first tried replacing all single quotes with ##Q## and then replacing them back e.g do a positive regular expression rather than a performance killing negative lookahead as it was HTML that used single rather than double quotes that was causing the issue e.g darkpolitricks.com instead of darkpolitricks.com
And if "hello" was a keyword I didn't want it putting a bolded/anchored tag inside the title attribute.
However that didn't work too well so I decided to store all the content of these attributes in an array and then replace them after all bolding and linking had been done.
However I really don't know why you are not getting a domain in your links as all the sites I use it on work (latest versions of WP but not multi sites)
Maybe you are using a multi site configuration or a non standard folder setup?
I am using get_option('siteurl') to get the site url which works fine for my own sites.
Feel free to replace or override that function with one of your choice e.g get_option('blogurl') or whatever you want.
You could even make it easy and hardcode that bit of code to your domain OR write a function at the bottom of the page to return your domain and replace any call of get_option('siteurl') with it e.g
Then replace all calls of get_option('siteurl') with getSiteDomain();