<s> import re <EOL> def findall ( data , regex ) : <EOL> p_reg = re . compile ( regex , re . DOTALL + re . MULTILINE + re . UNICODE ) <EOL> result = p_reg . findall ( data ) <EOL> return result <EOL> def parseTextToGroups ( txt , regex ) : <EOL> p = re . compile ( regex , re . DOTALL + re . MULTILINE + re . UNICODE ) <EOL> try : <EOL> m = p . match ( txt ) <EOL> if m : <EOL> return m . groups ( ) <EOL> else : <EOL> return None <EOL> except : <EOL> return None <EOL> def parseText ( txt , regex , variables = [ ] ) : <EOL> groups = parseTextToGroups ( txt , regex ) <EOL> if variables == [ ] : <EOL> if groups : <EOL> return groups [ <NUM_LIT:0> ] <EOL> else : <EOL> return '<STR_LIT>' <EOL> else : <EOL> resultArr = { } <EOL> i = <NUM_LIT:0> <EOL> for v in variables : <EOL> if groups : <EOL> resultArr [ v ] = groups [ i ] <EOL> else : <EOL> resultArr [ v ] = '<STR_LIT>' <EOL> i += <NUM_LIT:1> <EOL> return resultArr </s>
