Converting a Path to a string before regex matching