[Omaha.pm] /^\Q*****\E/

Jay Hannah jhannah at omnihotels.com
Wed Aug 16 11:37:03 PDT 2006


Gotta love \Q and \E in regex's. :)

  # Set the cc_number to empty if it matches asterisks.  The Reservation
class will ignore it.
  # This is so people can change the expiration or name on card for
modifications.
  #
  $cc_number = "" if ($cc_number =~ /^\Q*****\E/);

j

>From perldoc perlre:

  \Q          quote (disable) pattern metacharacters till \E

  Today it is more common to use the quotemeta()
  function or the "\Q" metaquoting escape sequence to dis-
  able all metacharacters' special meanings like this:

    /$unquoted\Q$quoted\E$unquoted/

  Beware that if you put literal backslashes (those not
  inside interpolated variables) between "\Q" and "\E", dou-
  ble-quotish backslash interpolation may lead to confusing
  results.  If you need to use literal backslashes within
  "\Q...\E", consult "Gory details of parsing quoted con-
  structs" in perlop.



More information about the Omaha-pm mailing list