def escapePattern(msg):
    """
    This method escapes regular expression characters in the string.
    And no, this is not re.escape, which would escape many more characters.

    @type msg: string
    @param msg: String that needs to be quoted

    @rtype: string
    @return: Escaped string for use in regular expressions
    """
    escapedStr = msg
    activeChars = ('\\', '[', ']', '{', '}', '(', ')', '*', '+', '?', '^',
        '$', '.', '|')
    for activeChar in activeChars:
        if activeChar in escapedStr:
            escapedStr = escapedStr.replace(activeChar, '\\' + activeChar)
    return escapedStr
