samedi 23 juillet 2016

Regex to search when a text is found and other text is missing

I have the following text:

application ONE {
    protocol tcp;
    destination-port 50;
}
application TWO {
    protocol udp;
    destination-port 51;
    inactivity-timeout 800;
}
application THREE {
    protocol udp;
    destination-port 500;
}

I need to search for each application, when protocol is udp, if inactivity-timeout is different from 1800 (app TWO) or protocol is udp and no inactivity is defined (app THREE). I've solved the first case with a regular expression:

(?s)(?=protocol udp).*(inactivity-timeout (?!1800))

But I've not found way to get the second.

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire