Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Usage of regular expression?

Expand Messages
  • J.E. Cripps
    ... all five? or words with any selection (aaiio, aeeou, eeeio)? ... Hint: /cat/ will match catalogue , concatenate wildcat ... this is IIRC perlrequick
    Message 1 of 10 , Dec 2, 2004
      > I am doing a exercise which requires me to find out all the words
      > that contains five vowels(a, e, I, o, u) from a text file.

      all five? or words with any selection (aaiio, aeeou, eeeio)?


      > I wrote a the following code to test it.
      > While(<>)
      > {
      > print if /aeiou/
      > }

      Hint: /cat/ will match "catalogue", "concatenate"
      "wildcat" ... this is IIRC perlrequick and perlretut.
      (the perldocs for regular expressions)
    • Mike Flannigan
      ... I would do: while ( ) { next unless tr/a//; next unless tr/e//; next unless tr/i//; next unless tr/o//; next unless tr/u//; print; } Mike
      Message 2 of 10 , Dec 3, 2004
        perl-beginner@yahoogroups.com wrote:

        >
        > Date: Thu, 02 Dec 2004 23:53:52 -0000
        > From: "Jeff Shu" <santa98bn@...>
        > Subject: Usage of regular expression?
        >
        > Hello everyone:
        >
        > Hello
        >
        > I am doing a exercise which requires me to find out all the words
        > that contains five vowels(a, e, I, o, u) from a text file.
        >
        > I wrote a the following code to test it.
        > While(<>)
        > {
        > print if /aeiou/
        > }
        >
        > but the result didn't show any words that contains five vowels. I
        > am
        > wondering what's wrong the my regular expression. Please give me
        > some
        > suggestions. Thanks!
        > Jeff
        > 12-02-04

        I would do:

        while (<>) {
        next unless tr/a//;
        next unless tr/e//;
        next unless tr/i//;
        next unless tr/o//;
        next unless tr/u//;
        print;
        }


        Mike
      Your message has been successfully submitted and would be delivered to recipients shortly.