E
ersin.er
Hi,
Say, I have a regexp like (\d)(?:,(\d))* which recognizes inputs like
"1", "0,4", "9,2,0", etc. What I want is to get all captured strings
from group 3 (and also the one from group 1). When the operation has
finished group 3 has only the last captured text which is the last
digit for this case. However I want to get all digits matched by group
1 and 3.
This is stated in API doc as follows:
"The captured input associated with a group is always the subsequence
that the group most recently matched. If a group is evaluated a second
time because of quantification then its previously-captured value, if
any, will be retained if the second evaluation fails. Matching the
string "aba" against the expression (a(b)?)+, for example, leaves group
two set to "b". All captured input is discarded at the beginning of
each match."
(
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#cg
)
You may advise to use splitting but it does not work for more complex
examples where delimitors are also included in the subgroups several
times.
Any suggestions?
Thanks in advance.
-- Ersin
Say, I have a regexp like (\d)(?:,(\d))* which recognizes inputs like
"1", "0,4", "9,2,0", etc. What I want is to get all captured strings
from group 3 (and also the one from group 1). When the operation has
finished group 3 has only the last captured text which is the last
digit for this case. However I want to get all digits matched by group
1 and 3.
This is stated in API doc as follows:
"The captured input associated with a group is always the subsequence
that the group most recently matched. If a group is evaluated a second
time because of quantification then its previously-captured value, if
any, will be retained if the second evaluation fails. Matching the
string "aba" against the expression (a(b)?)+, for example, leaves group
two set to "b". All captured input is discarded at the beginning of
each match."
(
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#cg
)
You may advise to use splitting but it does not work for more complex
examples where delimitors are also included in the subgroups several
times.
Any suggestions?
Thanks in advance.
-- Ersin