[ python-Bugs-1518453 ] '\' problem in re.sub
SourceForge.net
noreply at sourceforge.net
Fri Jul 7 08:21:49 CEST 2006
Bugs item #1518453, was opened at 2006-07-06 18:03
Message generated for change (Comment added) made by bos
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1518453&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: ilan29 (ilan29)
Assigned to: Nobody/Anonymous (nobody)
Summary: '\' problem in re.sub
Initial Comment:
#! /usr/bin/env python
import re
# Pattern only to match character 'b'
p = re.compile('b')
# Replace 'b' with SINGLE literal backslash
print p.sub( '\\', 'b', 1 )
I'm running:
Python 2.4.3 (#1, Jun 11 2006, 12:01:42)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
When starting the progam it raises:
sre_constants.error: bogus escape (end of line)
----------------------------------------------------------------------
Comment By: Bryan O'Sullivan (bos)
Date: 2006-07-06 23:21
Message:
Logged In: YES
user_id=28380
Your code is wrong. Both Python and re interpret
backslashes, and you're not passing enough backslashes in
for re to see two.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1518453&group_id=5470
More information about the Python-bugs-list
mailing list