Apologies for my poor understanding on the regex world. I'm trying to split a text using regex. Here's what I'm doing right now. Please consider the following string
String input = "Name:\"John Adam\" languge:\"english\" Date:\" August 2011\"";
Pattern pattern = Pattern.compile(".*?\\:\\\".*?\\\"\\s*");
Matcher matcher = pattern.matcher(input);
List keyValues = new LinkedList();
while(matcher.find()){
System.out.println(matcher.group());
keyValues.add(matcher.group());
}
System.out.println(keyValues);
I get the right output, which is what I'm looking.
Name:"John Adam"
languge:"english"
Date:" August 2011"
Now, I'm struggling to make it a little generic. For e.g. if I add another pattern in the input string. I've added a new value Audience:(user) in a different pattern, i.e. " is replaced by ();
String input = "Name:\"John Adam\" languge:\"english\" Date:\" August 2011\" Audience:(user)";
What'll be the generic pattern for this ? Sorry if this sounds too lame.
Thanks