http://qs321.pair.com?node_id=1078270


in reply to Dynamic matching

Given the user count is found by just counting the list, the following is sufficient.
my @strings = ( '8 changes by 4 users: user1 user2 user3 user4', '1 change by user1', ); for (@strings) { if (/^(\d+) change(?: by|s by \d+ users:) (.*)/) { my $changes = $1; my @users = split ' ', $2; print "changes=$changes, users=".@users.", list=@users\n"; } else { warn "Unrecognized string: $_\n"; } }
Outputs
changes=8, users=4, list=user1 user2 user3 user4 changes=1, users=1, list=user1
- Miller