1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/sqlliterals/regexp.py Sat Jun 02 19:41:22 2007 +0200
1.3 @@ -0,0 +1,21 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +import re
1.7 +query = re.compile("(?P<non_literal>[^']+)|(?P<literal>'(?:[^']|(?:''))*')")
1.8 +
1.9 +def parseString(s):
1.10 + regions = []
1.11 + first = 1
1.12 + for match in query.finditer(s):
1.13 + non_literal, literal = match.groups()
1.14 + if first and literal:
1.15 + regions.append("")
1.16 + if non_literal:
1.17 + regions.append(non_literal)
1.18 + elif literal:
1.19 + regions.append(literal)
1.20 + first = 0
1.21 +
1.22 + return regions
1.23 +
1.24 +# vim: tabstop=4 expandtab shiftwidth=4