I have a problem with this regex code to get text strings with apostrophes obtained through streaming. The code I use is this:
public static Map<String, String> parseMetadata(String metaString) {
Map<String, String> metadata = new HashMap<String, String>();
String[] metaParts = metaString.split(";");
Pattern p = Pattern.compile("^([a-zA-Z]+)=\'([^\']*)\'$");
Matcher m;
for (int i = 0; i < metaParts.length; i++) {
m = p.matcher(metaParts[i]);
if (m.find()) {
metadata.put(m.group(1), m.group(2));
Log.d("MAP", String.valueOf(metadata));
}
}
return metadata;
}
This part of the code is what gives me problems
Pattern p = Pattern.compile("^([a-zA-Z]+)=\'([^\']*)\'$");
And this is an example of text (there can only be a single title in the string):
StreamTitle='The Swirling Eddies - Don't Ask Me How I Feel';
The problem is that if there is a song that has the title with apostrophe , it does not show it to me and the titles with hyphens, brackets or accents if.
For example if the title is like this: Can't play
, it does not show me the text string, and what I'm looking for is to show it with everything and apostrophe.