in reply to Counting frequency of expressions in a string
You need the g (global) modifier and possibly the s (ignore line ends) modifier. You also need to remove the $ (end of pattern match). You also need to match "Perl Party".
Test code would look something like this:
Update: /s removed and relevant comment struck. See bart's reply below.use strict; use warnings; my @dates; my $string = do {$/ = ""; <DATA>}; while ($string =~ /\b(\d{2})-(\d{2})-(\d{4})\sPerl\sParty/g) { push @dates, "$1\.$2\.$3"; } print join "\n", @dates; __DATA__ All kinds of text 01-01-2003 Perl Party more text 01-01-2004 Perl Part +y and even more text 01-01-2005 Perl Party and finally some other date 01-01-2006
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting frequency of expressions in a string
by bart (Canon) on Aug 29, 2005 at 10:25 UTC | |
by holli (Abbot) on Aug 29, 2005 at 10:33 UTC | |
by GrandFather (Saint) on Aug 29, 2005 at 11:28 UTC |