Extract purity from string