I have a simple regular expression which looks something like
([a-z]*)( +[a-z]="[0-9]")*
and it works in matching patterns like
test a="1" b="2" c="3"...
Is there any way of capturing each of the name-value pairs (e.g., a=”1″) in a separate matcher group?
As it is in the above example, I get a matcher group for (test) and only one matcher group for the 3 name-value pairs (i.e., the last one, c=”3″). I would expect 3 matcher groups, 1 for each such pair.
No, it’s two groups in total. The only way to get the key-value pairs in three groups, is by doing:
You could match all key value pairs in a single group and then use a separate Pattern & Matcher on it:
which produces: