And take out .*? You probably want .+? Since this will grab at least one character for sure. Also, adding an else clause after the if would be a good way to notify the user if there is not match, or to provide a default location, like 'no location given'.