Groovy web console

subscribe to the feed Subscribe
to this
site

extract data

Published 3 weeks ago by tabassum with tags using regex
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def output  = """ define contact{        contact_name                    IPNOC
        alias                           Network Monitoring Center
        email                           ip-noc@libertyglobal.com
        use    default_user
        }
define contact{
        contact_name                    dmariuscatalin
        alias                           Diaconu Mariuscatalin
        email                           madiaconu.contractor@libertyglobal.com
        use                             default_user
        }
define contact{
        contact_name                    egriffiths
        alias                           Eddie Griffiths
        email                           egriffiths@libertyglobal.com
        use                    notif_disabled
        }
define contact{
        contact_name                    jcollis
        alias                           James Collis
        email                           jcollis@libertyglobal.com
        use    default_user

        }"""
def result = [:]
def con = output.findAll(/(?<=contact_name).*/)
def data = output.findAll(/(?<=alias).*/)

for(i=0; i<data.size; i++)
{
result.put(con[i],data[i])
}
println result