refactored string_extract.R