Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!gatech!psuvax1!news From: flee@cs.psu.edu (Felix Lee) Newsgroups: comp.lang.perl Subject: Re: pattern1 AND pattern2? Message-ID: <&9bGb9yz1@cs.psu.edu> Date: 27 Apr 91 08:17:18 GMT References: <130399@uunet.UU.NET> <1991Apr25.201644.1546@agate.berkeley.edu> Sender: news@cs.psu.edu (Usenet) Organization: ~/News/org Lines: 21 Nntp-Posting-Host: dictionopolis.cs.psu.edu Raymond Chen poses: > / \S* \S* &[^aeiou]*a[^aeiou]*e[^aeiou]*i[^aeiou]*o[^aeiou]*u[^aeiou]*/ >which matches two consecutive words which together use all the vowels >in order. Well, you could write this as one long regexp, but the technique isn't easily to generalize. The way to do this in Perl is to write a loop: $x = "Do not name pious mermaids Fred."; while ($x ne '' && $x =~ / \S* \S* /) { $m = $&; $x = substr($& . $', 1); if ($m =~ /^[^aeiou]*a[^aeiou]*e[^aeiou]*i[^aeiou]*o[^aeiou]*u[^aeiou]*$/) { print "$&\n"; } } Note that there are at least four different interpretations of pattern conjunction. This loop expresses only the simplest. -- Felix Lee flee@cs.psu.edu