[Tutor] question regarding regular expression compile
Luke Paireepinart
rabidpoobear at gmail.com
Thu Jan 13 01:06:37 CET 2011
No. Did you try that? It doesn't evn look like valid python code to me.
You want a single string with the r before it, not 3 separate strings.
-----------------------------
Sent from a mobile device. Apologies for brevity and top-posting.
-----------------------------
On Jan 12, 2011, at 8:02 AM, "Yaniga, Frank" <Frank.Yaniga at GDIT.com> wrote:
> I believe I had epiphany:
>
> test = re.compile('MAT file (billing|carrier|log|util)' r'\\' '\d{8} deleted')
>
> is this correct?
>
> _____________________________________________
> From: Yaniga, Frank
> Sent: Wednesday, January 12, 2011 8:20 AM
> To: 'tutor at python.org'; 'help at python.org'
> Subject: question regarding regular expression compile
>
>
> I am determining a regular expression that can recognize the any of the following strings:
>
> MAT file log\20101225 deleted
> MAT file billing\20101225 deleted
> MAT file util\20101225 deleted
> MAT file carrier\20101225 deleted
>
> I begin by creating a regular expression object so that I can reuse it in multiple operations:
>
> test = re.compile(‘MAT file
>
> for log, billing, util, and carrier I use an arbitrary match:
>
> (log|billing|util|carrier)
>
> for 20101225 I use decimal digit with repetition match:
>
> \d{8}
>
> and finish with:
>
> delete’)
>
>
> My question is how do I handle the backslash (NOTE: the match must only be a backslash)?
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110112/6e49fdc4/attachment-0001.html>
More information about the Tutor
mailing list