in reply to Re^3: regexp - replace spaces in quoted string
in thread regexp - replace spaces in quoted string

While the explanation provided by YAPE::Regex::Explain will probably be inferior to that which a human well-versed in regexps could produce, the advantage in using the module is that an explanation can be produced without having access to the well-versed human. It is available to anyone with access to CPAN, and therefore can be quite useful to the learner. :-)

planetscape
  • Comment on Re^4: regexp - replace spaces in quoted string

Replies are listed 'Best First'.
Re^5: regexp - replace spaces in quoted string
by japhy (Canon) on Sep 06, 2005 at 13:49 UTC
    Um, you mis-used my module. Only the LEFT-HAND side of a s/// is a regex; therefore, only the left-hand side should be sent through YAPE::R::E.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      Oopsie. I'm on drugs - that's my excuse.

      (No, really - oral surgery last Wednesday. That's my story, and I'm sticking to it!)

      Corrected stuff:

      The regular expression: (?-imsx:(".*?")) 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): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- " '"' ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- " '"' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

      The point about YAPE::Regex::Explain being useful to someone learning regexes is still perfectly valid, despite my mistake. :-)

      planetscape
      Sounds like a feature request to me. ;)

      Another suggestion: if the whole regex is surrounded by a fully qualified (?xi-sm: ... ) block, then it's likely created by the qr// stringification, and not as presented. I would consider stripping that off and then explain the modes at the end along with any /g /e explanations.

      --
      [ e d @ h a l l e y . c c ]