A
Ajay
hi!
i got the escape character bit, but i still get an errorTraceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\Python23\lib\sre.py", line 151, in subn
return _compile(pattern, 0).subn(repl, string, count)
File "c:\Python23\lib\sre.py", line 258, in _subx
template = _compile_repl(template, pattern)
File "c:\Python23\lib\sre.py", line 245, in _compile_repl
raise error, v # invalid expression
sre_constants.error: bogus escape (end of line)
any ideas?
cheers
--
Ajay Brar,
CS Honours 2004
Smart Internet Technology Research Group
i got the escape character bit, but i still get an errorTraceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\Python23\lib\sre.py", line 151, in subn
return _compile(pattern, 0).subn(repl, string, count)
File "c:\Python23\lib\sre.py", line 258, in _subx
template = _compile_repl(template, pattern)
File "c:\Python23\lib\sre.py", line 245, in _compile_repl
raise error, v # invalid expression
sre_constants.error: bogus escape (end of line)
any ideas?
cheers
--
Ajay Brar,
CS Honours 2004
Smart Internet Technology Research Group
Quoting Gandalf said:Hi Ajay!
The problem is that you must represent the backslash as '\\'. This is
because a simple backslash opens an escape sequence.
For example:
'\n' - this is new line
'\t' - this is TAB
'\\' - this is the backslash itself
You should use this:
re.subn('/', '\\', str)
The other way is to use raw strings. You can read more about these
things here:
http://docs.python.org/ref/strings.html
Best,
Laci 2.0