searching three different words using regex in python
Question: I am trying to search three different words in the below output

    
    
    +---------------------+---------------------------+------------------+------------+-----------+------------+----------+-------------------+----------------+
    |    radius-server    |           address         |      secret      |  auth-port |  acc-port |  max-retry |  timeout |    nas-ip-local   |  max-out-trans |
    +---------------------+---------------------------+------------------+------------+-----------+------------+----------+-------------------+----------------+
    |              rad_11 |                 127.0.0.1 |       testing123 |       9812 |      9813 |          5 |       10 |           disable |            200 |
    +---------------------+---------------------------+------------------+------------+-----------+------------+----------+-------------------+----------------+
    

They are `rad_11`, `127.0.0.1` and `testing123`. Can someone help me out ?

I have tried `re.search ('rad_11' '127.0.0.1' 'testing123', output)`.


Answer: You can clear all unnecessary symbols and parse the string:

    
    
    import re
    
    new_string = re.sub('\+[\-]*|\n', '', a).strip(' |').replace('||', '|')
    
    names_values = map(lambda x: x.strip(' |\n'), filter(bool, new_string.split(' | ')))
    
    count_of_values = len(names_values)/2
    names, values = names_values[:count_of_values], names_values[count_of_values:]
    print dict(zip(names, values))
    
    >>> {'max-out-trans': '200', 'nas-ip-local': 'disable', 'address': '127.0.0.1', 
     'radius-server': 'rad_11', 'secret': 'testing123', 'acc-port': '9813', 
     'timeout': '10', 'auth-port': '9812', 'max-retry': '5'}
    

