Best function/method to access wp-config?

I am not aware of a WordPress function to do this. But have a look at this search and replace tool:

https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

This achieves what you want by reading in the wp-config file and scanning through it. Have a look at the function “icit_srdb_define_find” on line 374.