I agree that a generic parser as suggested by ikegami is probably the best approach.
However, here's a regex solution to the specific problem. Note this assumes only one BYDAY field per line/record; if there are more, all field values are extracted indiscriminately.
>perl -wMstrict -le "my @tests = ( 'RRULE:FREQ=WEEKLY;BYDAY=TU,TH;UNTIL=20110429T000000;WKST=SU', 'RRULE:FREQ=WEEKLY;BYDAY=TU;UNTIL=20110429T000000;WKST=SU', 'RRULE:FREQ=WEEKLY;BYDAY=TU,TH,FR;UNTIL=20110429T000000;WKST=SU', 'BYDAY=MO,WE;FOO;BYDAY=TU,TH;BAR', ); ;; for my $test (@tests) { my @bydays = $test =~ m{ (?: BYDAY= | \G ,) ([A-Z]+) }xmsg; print qq{@bydays}; } " TU TH TU TU TH FR MO WE TU TH
In reply to Re: Capturing unknown number of matches
by AnomalousMonk
in thread Capturing unknown number of matches
by awygle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |