From: <Paul_Koning@Dell.com>
To: <joachim.protze@tu-dresden.de>
Cc: <graham.labdon@avalonsciences.com>, <gdb@sourceware.org>
Subject: Re: help with pretty printing
Date: Thu, 07 Jun 2012 18:27:00 -0000 [thread overview]
Message-ID: <D7A359B3-DDB9-4AD9-A136-072CDC18B155@dell.com> (raw)
In-Reply-To: <4FD05B70.7040008@tu-dresden.de>
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$')] = lambda
>> val:QFilePrinter(val)
>> pretty_printers_dict[re.compile ('^QFile *$')] = lambda
>> val:QFilePrinter(val)
> you may try something like the following to match both cases:
>
> pretty_printers_dict[re.compile('^QFile ( \*)?$')] = lambda
> val:QFilePrinter(val)
>
>
> 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 spaces as postfix.
>
> - Joachim
Yes, but since you're dealing with a regular (not raw) string here, the \ needs to be doubled, otherwise it is treated as a string character escape instead of a backslash character inside the string. So one of these will match space followed by asterisk:
pretty_printers_dict[re.compile('^QFile ( \\*)?$')] = lambda val:QFilePrinter(val)
pretty_printers_dict[re.compile(r'^QFile ( \*)?$')] = lambda val:QFilePrinter(val)
next prev parent reply other threads:[~2012-06-07 18:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 9:07 somersetgraham
2012-06-02 5:28 ` Niko Sams
2012-06-02 10:29 ` xgsa
2012-06-02 11:10 ` Niko Sams
2012-06-02 11:24 ` xgsa
2012-06-07 7:42 ` Joachim Protze
2012-06-07 18:27 ` Paul_Koning [this message]
2012-06-25 11:05 ` Joachim Protze
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D7A359B3-DDB9-4AD9-A136-072CDC18B155@dell.com \
--to=paul_koning@dell.com \
--cc=gdb@sourceware.org \
--cc=graham.labdon@avalonsciences.com \
--cc=joachim.protze@tu-dresden.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox