From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8363 invoked by alias); 7 Jun 2012 18:27:13 -0000 Received: (qmail 8354 invoked by uid 22791); 7 Jun 2012 18:27:12 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ausxippc101.us.dell.com (HELO ausxippc101.us.dell.com) (143.166.85.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jun 2012 18:26:59 +0000 X-Loopcount0: from 10.175.216.250 From: To: CC: , Subject: Re: help with pretty printing Date: Thu, 07 Jun 2012 18:27:00 -0000 Message-ID: References: <33943560.post@talk.nabble.com> <4FD05B70.7040008@tu-dresden.de> In-Reply-To: <4FD05B70.7040008@tu-dresden.de> Content-Type: text/plain; charset="us-ascii" Content-ID: <710BDC5801379C4EAE086BCD03676516@dell.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-06/txt/msg00042.txt.bz2 On Jun 7, 2012, at 3:42 AM, Joachim Protze wrote: > On 01.06.2012 11:07, somersetgraham wrote: >> def build_dictionary (): >> pretty_printers_dict[re.compile ('^QFile$')] =3D lambda >> val:QFilePrinter(val) >> pretty_printers_dict[re.compile ('^QFile *$')] =3D lambda >> val:QFilePrinter(val) > you may try something like the following to match both cases: >=20 > pretty_printers_dict[re.compile('^QFile ( \*)?$')] =3D lambda > val:QFilePrinter(val) >=20 >=20 > The asterisk is a special character in regular expressions and has to be = escaped to match an asterisk. Your regexp matches QFile with any count of s= paces as postfix. >=20 > - Joachim Yes, but since you're dealing with a regular (not raw) string here, the \ n= eeds to be doubled, otherwise it is treated as a string character escape in= stead of a backslash character inside the string. So one of these will mat= ch space followed by asterisk: pretty_printers_dict[re.compile('^QFile ( \\*)?$')] =3D lambda val:QFilePri= nter(val) pretty_printers_dict[re.compile(r'^QFile ( \*)?$')] =3D lambda val:QFilePri= nter(val)