Commits

Anonymous committed f231a1c

simplified regexp for string literals

Comments (0)

Files changed (1)

rope/base/codeanalyze.py

 
 def get_string_pattern():
     start = r'(\b[uU]?[rR]?)?'
-    return '|'.join([r"%s'''[^'\\]*((\\.|'(?!'')|\\\n)[^'\\]*)*(''')?" % start,
-                     r'%s"""[^"\\]*((\\.|"(?!"")|\\\n)[^"\\]*)*(""")?' % start,
-                     r"%s'[^'\\\n]*(\\.[^'\\\n]*)*'?" % start,
-                     r'%s"[^"\\\n]*(\\.[^"\\\n]*)*"?' % start])
+    longstr = r'%s"""(\\.|"(?!"")|\\\n|[^"\\])*"""' % start
+    shortstr = r'%s"(\\.|[^"\\\n])*"' % start
+    return '|'.join([longstr, longstr.replace('"', "'"),
+                     shortstr, shortstr.replace('"', "'")])
 
 def get_comment_pattern():
     return r'#[^\n]*'