Actually, this doesn't work. The string you show has two characters,
both of them backslashes. The r prefix means that backslashes aren't
escapes, they're literal backslash characters. Unfortunately, there's a
flaw in the Python lexer which means you can't use a single backslash
here either
I would use a raw string like this"
string.rfind(r'\\')
The raw string makes sure there is no additional escaped special
characters. But you still need to escape the backslash.
Here is a good read on all this:
http://www.python.org/doc/current/ref/strings.html
+ Leeland
--~--~-~--~---
Haha. so obvious. Thanks Malcolm
On Jun 28, 9:25 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2008-06-28 at 01:17 -0700, Jarred Bishop wrote:
> > hello, I'm trying to get the index of the last backslash from a string
> > in python.
>
> > The problem I have is that the backslash bef
On Sat, 2008-06-28 at 01:17 -0700, Jarred Bishop wrote:
> hello, I'm trying to get the index of the last backslash from a string
> in python.
>
> The problem I have is that the backslash before the last quotation
> mark, cancels out the quote.
>
> eg: string.rfind("\") will error, because techn
hello, I'm trying to get the index of the last backslash from a string
in python.
The problem I have is that the backslash before the last quotation
mark, cancels out the quote.
eg: string.rfind("\") will error, because technically the string isn't
closed (as a backslash before a quote escapes i
5 matches
Mail list logo