I am trying to create a regex expression that would match one or multiple variable value assignments on the same line. I am using the following expression:
([a-z][a-zA-Z0-9-]*)=(('(\'|[^\'])*')|("(\"|[^"])*"))
For example, if I have the following string as input:
a="xyz" b="hello world"
And using the following code:
Matcher matcher = rules.get(regex).matcher(input);
int start = 0;
while (matcher.find(start)) {
System.err.println(matcher.group(0));
start = matcher.end();
}
It should give me two seperate results:
1. a="xyz"
2. b="hello world"
But it only returns one, the entire input string.
a="xyz" b="hello world"
It seems to be taking xyz" b="hello world as the inner part. How can I resolve this?
([a-z][a-zA-Z0-9-]*)=(('([^']*)')|("([^"]*)")), demo"likea="xyz" b="hell\"o world"