[Tutor] Regex with Python

Gerrit Holl gerrit@nl.linux.org
Fri, 3 Dec 1999 13:49:38 +0100


Oscar Picasso wrote:
> Hi,
> 
> I don't know if the problem I have specific to Python or it is I
> misunderstand regexes. Here is my code:
> 
> import re
> 
> st='This is string. "With a quoted \\"string\\" inside it." A single quote
> ". Here is the end of the string.'
> 
> s='("([^"]|(\\"))*")'
> 
> pat=re.compile(s)
> r=pat.search(st)
> print r.group(0)
> >>> "With a quoted \"string\" inside it." A single quote "
> 
> I expected:
> >>> "With a quoted \"string\" inside it."
> 
> I don't see where is my mistake. 

s=r'("([^"]|(\\"))*")'

r=raw

regards,
Gerrit.


-- 
"The world is beating a path to our door"

  -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates)
  1:49pm  up  1:23, 14 users,  load average: 0.00, 0.00, 0.00