R
Remko Silvis
Hi can anyone help me understand the following
I have a regular expression that has to match for example:
<format zipped="false" encrypted="false" />
My expression:
Pattern singleTag = Pattern.compile("< *(\\w+) *(\\w+\\=\"\\w+\" *)*/>");
matches only 3 Groups
group(0) = <format zipped="false" encrypted="false" />
group(1) = format
group(2) = encrypted="false"
it skippes the 'zipped="false"' argument.
When i change the regexp to fit this string exactly,
like this:
Pattern singleTag = Pattern.compile("< *(\\w+) *(\\w+\\=\"\\w+\"
*)(\\w+\\=\"\\w+\" *)/>");
i get the four groups i expect:
group(0) = <format zipped="false" encrypted="false" />
group(1) = format
group(2) = zipped="false"
group(4) = encrypted="false"
it seams that repeating a group '()*' does not create a new group, but
overwrites the previous one.
Can anyone confirm this?
Thanx,
Remko
I have a regular expression that has to match for example:
<format zipped="false" encrypted="false" />
My expression:
Pattern singleTag = Pattern.compile("< *(\\w+) *(\\w+\\=\"\\w+\" *)*/>");
matches only 3 Groups
group(0) = <format zipped="false" encrypted="false" />
group(1) = format
group(2) = encrypted="false"
it skippes the 'zipped="false"' argument.
When i change the regexp to fit this string exactly,
like this:
Pattern singleTag = Pattern.compile("< *(\\w+) *(\\w+\\=\"\\w+\"
*)(\\w+\\=\"\\w+\" *)/>");
i get the four groups i expect:
group(0) = <format zipped="false" encrypted="false" />
group(1) = format
group(2) = zipped="false"
group(4) = encrypted="false"
it seams that repeating a group '()*' does not create a new group, but
overwrites the previous one.
Can anyone confirm this?
Thanx,
Remko