extract and merge strings