Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: regex to find vowels in anyorder

by JavaFan (Canon)
on Dec 19, 2011 at 17:58 UTC ( #944287=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex to find vowels in anyorder
in thread regex to find vowels in anyorder

I wouldn't do this as an "anded if" but in a loop with an array of vowels. As soon as the script has found the first vowel the script would continue with the next vowel but if the vowel wasn't found it would stop the whole search as it's not interesting whether the other vowels are in the string.
Uhm, in which way does an "anded if" continue with a next vowel after a previous vowel wasn't found?

Replies are listed 'Best First'.
Re^4: regex to find vowels in anyorder
by ww (Archbishop) on Dec 19, 2011 at 21:06 UTC
    If the first is not found, you're done, per OP's spec: "all 5 vowels"
      You also asked (in a message, but the answer is way to lengthy for the peephole messages force you to use):
      Perhaps I fail to understand your question. My comment predicated on the fact that if a vowel is absent, continuation is moot. Not so?
      Let me explain the sequence of events:
      1. varghees asks the original question how to write a regexp matching all five vowels.
      2. SuicideJunkie gives the obvious answer, the "anded if".
      3. leuchuk replies to SuicideJunkie, saying he wouldn't use the "anded if" solution, but an array based on because As soon as the script has found the first vowel the script would continue with the next vowel but if the vowel wasn't found it would stop the whole search as it's not interesting whether the other vowels are in the string.
      4. I ask leuchuk why he'd choose that solution over the "anded if", as the "anded if" also gives that benefit (you, know, short-circuiting logic operators) -- but leuchuk seems to suggest that it doesn't.
      5. You reply to me with If the first is not found, you're done, per OP's spec: "all 5 vowels". Noone in this sequence of posts leading up to yours has giving even the most remote inkling that he was thinking it was about anything else but matching all 5 vowels.
      So, let me repeat my question, how does your reply to me answer the question why doesn't an "anded if" stop if a vowel isn't found? It's not that what you say is wrong, it's just that you're stating something irrelevant as it doesn't even try to answer the question.
        Ah-ha! The light comes on...
        but I still think one of us is mis-reading the node in question -- either by reading something into it (you) or failing to see a blind spot in leuchuk's understanding of short-circuiting (me).

        Quoting what seem to me to be the relevant lines:

        "As soon as the script has found the first vowel the script would continue with the next vowel but if the vowel wasn't found it would stop the whole search as it's not interesting whether the other vowels are in the string."
        1. Thru "the next vowel" is irrelevant to our disagreement.
        2. beginning with "but if..." thru "the whole search" - while your supposition about leuchuk's understanding of the operation of "and-ed ifs" may be accurate, I don't see any strong reason for that supposition. Consider, if you will, this pseudocode paraphrase of the the "but if ...the whole search" component of that clause:
          if (some vowel ! found ) { exit; }

        The end of that sentence, "as it's not interesting whether the other vowels are in the string", seems to me to be no more or less than a second restatement of OP's spec -- all five vowels -- attributed by leuchuk at this point to "the script" he's talking about.

        I hate to invoke a pro sports rule, but it seems to fit here: if the instant replay fails to show incontrovertible evidence that the call on the field was wrong, the call stands. Stretching the parallel almost to the breaking point, I think you've superimposed a supposition -- possible but unproven, to me -- over the replay.

      If the first is not found, you're done, per OP's spec: "all 5 vowels"
      How does that answer my question?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://944287]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2021-10-28 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (95 votes). Check out past polls.

    Notices?