enttoobad has asked for the wisdom of the Perl Monks concerning the following question:


Is anyone able to explain what this perl regex matches?


Many thanks

Replies are listed 'Best First'.
Re: A regular expression
by dorko (Parson) on Mar 22, 2012 at 13:38 UTC
    I use YAPE::Regex::Explain to explain Regular Expressions:
    use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/999[89]\$/)->explain(); __END__ The regular expression: (?-imsx:999[89]\$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- 999 '999' ---------------------------------------------------------------------- [89] any character of: '8', '9' ---------------------------------------------------------------------- \$ '$' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------



    -- Yeah, I'm a Delt.
      that's a handy tool, thanks!
Re: A regular expression
by JavaFan (Canon) on Mar 22, 2012 at 13:27 UTC
    Any string that contains either 9998$ or 9999$.
      great, thanks very much!
Re: A regular expression
by GrandFather (Sage) on Mar 22, 2012 at 20:15 UTC

    You should take a good look at least at perlretut, and probably at some of the other Perl regular expression documentation.

    True laziness is hard work
Re: A regular expression
by planetscape (Chancellor) on Mar 24, 2012 at 22:54 UTC