http://qs321.pair.com?node_id=402376


in reply to Re: Regex help
in thread Regex help

or
/B(?:3[89]|4\d)/
or
/B(?!3[0-7])[34]\d/
or
/B(\d\d)(?(?{ $1 < 38 || $1 > 49 })(?=A)(?=Z))/

Replies are listed 'Best First'.
Re^3: Regex help
by C_T (Scribe) on Oct 26, 2004 at 17:44 UTC
    /B(?:3[89]|4\d)/
    This worked like a charm, and really helped me understand the proper syntax of the conditional test.

    Thanks much!

    CT

    Charles Thomas
    Madison, WI
      (?(?{code}true-regexp) (?(?{code}true-regexp|false-regexp) / B (\d\d) (? (?{ $1 < 38 || $1 > 49 }) # if invalid (?=A)(?=Z) # then fail # else succeed ) /x

      It could also have been written:

      / B (\d\d) (?(?{ $1 >= 38 && $1 <= 49 }) # if valid # succeed | # else (?=A)(?=Z) # fail ) /x

      (?=A)(?=Z) means the next char must be an 'A' and must be a 'Z'. That's never gonna happen.