Extracting parts of strings using regular expressions