vendredi 21 juillet 2017

RegEx match for groups that show up in different order

I’m trying to come-up with a RegEx Match Pattern (preferably for Python) for the following possible strings combinations. These are JVM generic args strings with –D switches that may appear in any random order…

How do I account for such random-ness in my RegEx?

So far I have this, but it doesn't work for all the scenarios below. Matches only #1

\-javaagent:.+\/javaagent.jar\s+-Dappdynamics\.agent\.applicationName=[A-Za-z0-9\-\_]+\s+-Dappdynamics\.agent\.tierName=[A-Za-z0-9\-\_]+\s+\-Dappdynamics\.agent\.nodeName=[A-Za-z0-9\-\_\$\{\}]+\s+\-Dappdynamics\.agent\.uniqueHostId=[A-Za-z0-9\-\_\$\{\}]+

Search contexts:

1.

-javaagent:/path/to/folder/with/javaagent.jar -Dappdynamics.agent.applicationName=1234_APP-NAME -Dappdynamics.agent.tierName=myTIER-NAME -Dappdynamics.agent.nodeName=${WAS_SERVER_NAME} -Dappdynamics.agent.uniqueHostId=${HOSTNAME}

2.

-javaagent:/path/to/folder/with/javaagent.jar -Dappdynamics.agent.tierName=myTIER-NAME -Dappdynamics.agent.applicationName=1234_APP-NAME -Dappdynamics.agent.nodeName=${WAS_SERVER_NAME} -Dappdynamics.agent.uniqueHostId=${HOSTNAME}

3.

-javaagent:/path/to/folder/with/javaagent.jar -Dappdynamics.agent.uniqueHostId=${HOSTNAME} -Dappdynamics.agent.applicationName=1234_APP-NAME -Dappdynamics.agent.tierName=myTIER-NAME -Dappdynamics.agent.nodeName=${WAS_SERVER_NAME}




Aucun commentaire:

Enregistrer un commentaire