in reply to Dynamic matching
Given the user count is found by just counting the list, the following is sufficient.
Outputsmy @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"; } }
- Millerchanges=8, users=4, list=user1 user2 user3 user4 changes=1, users=1, list=user1
In Section
Seekers of Perl Wisdom