def _findString(text, s, i):
    """ Helper function of findString, which is called recursively
    until a match is found, or it is clear there is no match. """
    i2 = text.find(s, i)
    if i2 < 0:
        return -1
    i1 = text.rfind('\n', 0, i2)
    if i1 < 0:
        return i2
    line = text[i1:i2]
    if not line.count('"') and not line.count("'") and not line.count('#'):
        return i2
    prev = ''
    inString = ''
    isComment = False
    for c in line:
        if c == '#':
            if not inString:
                isComment = True
                break
        elif c in '"\'':
            if not inString:
                inString = c
            elif prev != '\\':
                if inString == c:
                    inString = ''
                else:
                    pass
        prev = c
    if inString or isComment:
        return -i2
    else:
        return i2
