Issue 1518453: '' problem in re.sub (original) (raw)
Issue1518453
Created on 2006-07-07 01:03 by ilan29, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg29087 - (view) | Author: ilan29 (ilan29) | Date: 2006-07-07 01:03 |
#! /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) | ||
msg29088 - (view) | Author: Bryan O'Sullivan (bos) | Date: 2006-07-07 06:21 |
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. | ||
msg29089 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2006-07-07 07:47 |
Logged In: YES user_id=849994 bos is right. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:18 | admin | set | github: 43629 |
2006-07-07 01:03:21 | ilan29 | create |