(value, charRegex, replacement="")
return retVal
Returns string value consisting only of chars satisfying supplied
    regular expression (note: it has to be in form [...])

    >>> filterStringValue(u'wzydeadbeef0123#', r'[0-9a-f]')
    u'deadbeef0123'
Returns string value consisting only of chars satisfying supplied
    regular expression (note: it has to be in form [...])
Returns string value consisting only of chars satisfying supplied regular expression ( note : it has to be in form [ ... ] )
def filterStringValue(value, charRegex, replacement=""):
    """
    Returns string value consisting only of chars satisfying supplied
    regular expression (note: it has to be in form [...])

    >>> filterStringValue(u'wzydeadbeef0123#', r'[0-9a-f]')
    u'deadbeef0123'
    """

    retVal = value

    if value:
        retVal = re.sub(charRegex.replace("[", "[^") if "[^" not in charRegex else charRegex.replace("[^", "["), replacement, value)

    return retVal
def filterStringValue ( value , charRegex , replacement = "" ) : retVal = value if value : retVal = re . sub ( charRegex . replace ( "[" , "[^" ) if "[^" not in charRegex else charRegex . replace ( "[^" , "[" ) , replacement , value ) return retVal