I am trying to parse lines of the form:
command arg1 [ Arg2, ... argn]
like:
or
f 1/2/3 4/5/6 7/8/9
Here's my Reggae:
^ (\\ W +) ($ \\ S +) +) $
When I parse the "usemtl weasels" line, I get the following capturing groups:
<0> Match 0: 'USMTL Weasels' match 1: 'USMTL' match 2: 'electricity'
Why start with another match group Location? It does not appear in Rubular. Grouping in Java Regex is a bit awkward Group 0 gives you a complete mail of your regex - all of these are regex.
Implementation is similar to what I know. But n ( n = 1) will give you n the last match of the declared group, not n got the match.
Your second match gives you 'Weasels' with a prominent space, because your pattern is empty, you declare your second group ((\\ S +) +)
And this group gives you another match.
If you apply your pattern to string abcd
, your group will be 0 abcd
, group 1 will a
, Group 2 will be bcd
and group 3 will be d
, because it is your third declared (internal) group (\\ S +)
.
Comments
Post a Comment