in reply to reg expression

A1: say "M K Gandhi" if /^\QMohandas Karamchand Gandhi\E\z/;

A2: How are the clauses to be taken? Disjunctions? Conjunctions? Juxtapositions? The latter seems the most logical, but then, why not just use "followed by", which is used on clauses a) and b)? And since clause b) matches any string, disjunctions seems unlikely. Leaves us conjunctions. But then the answer ought to be: it's better done with three regular expressions.

Replies are listed 'Best First'.
Re^2: reg expression
by CountZero (Bishop) on Aug 29, 2011 at 16:11 UTC
    A2: How are the clauses to be taken?
    I think it are three separate questions a), b) and c).

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      I think it are three separate questions a), b) and c)
      That's what I initially thought as well. But the question states a regular expression, not regular expressions. It also means the teacher likes trick questions, as the answer to b) is any pattern that matches the empty string. It doesn't mean you're wrong - I just didn't find it likely.
        It also means the teacher likes trick questions
        Bad teacher.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James