T
teds
Hi,
I'm trying to parse out all the letters in an expression like this:
A, B, C
where I won't know ahead of time how many letters I'll have (i.e., it
could be A, B, C, D, E, F ). So I tried this:
$str =~ / (\w*\,\s*)+ \s (\w*) /
on A, B, C
and what I get for $1=B, $2 = C. It seems that $1 is giving me the
last
entry in the match of A, B,. I want to get A as well so I thought I
would make sure I have 1 match of (\w*\,\s*)+. When I do the
following:
$str =~ / ( ( \w*\,\s* )+ ){1} \s (\w*) /
I now get $1 = A, B, but now $2 is B, and $3 is C.
I'm curious why $2 = B, and also wonder if there's a better way of
doing this.
Thanks,
Ted
I'm trying to parse out all the letters in an expression like this:
A, B, C
where I won't know ahead of time how many letters I'll have (i.e., it
could be A, B, C, D, E, F ). So I tried this:
$str =~ / (\w*\,\s*)+ \s (\w*) /
on A, B, C
and what I get for $1=B, $2 = C. It seems that $1 is giving me the
last
entry in the match of A, B,. I want to get A as well so I thought I
would make sure I have 1 match of (\w*\,\s*)+. When I do the
following:
$str =~ / ( ( \w*\,\s* )+ ){1} \s (\w*) /
I now get $1 = A, B, but now $2 is B, and $3 is C.
I'm curious why $2 = B, and also wonder if there's a better way of
doing this.
Thanks,
Ted