I am trying to come up with a regular expression in Perl matching multiple patterns and returning all of them like preg_match_all
in PHP does.
Here\'s w
The Perl equivalent to
preg_match_all('/(test|data|string)/', 'testdatastring', $m)
is
@m = ("testdatastring" =~ m/(test|data|string)/g);
The /g flag stands for global, so it returns a list of matches in list context.
See http://www.anaesthetist.com/mnm/perl/regex.htm . Basic syntax (from there) is:
$_ = "alpha xbetay xgammay xdeltay so on";
($first, $second, $third) = /x(.+?)y/g;
Note the /g