Useful regular expressions

Regular expressions can be used in different Measure definitions, such as URI Pattern or Cookie Values. Regular expressions are very powerful but sometimes a little hard to write if not working with them regularly. This page shows useful Regular expressions frequently used in their AppMon Installation. You can use them to leverage regular expressions for your measures.

Besides the built-in Regular Expression Tester in most AppMon dialog boxes, you can also check out this online regex testing service: http://www.regextester.com/

See http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html for a documentation of regular expression syntax.

Pulling a value from a method argument (for example an XML field)

Full Method Argument: RegEx: Returns:
<XML File> Value1="1234" Value2="5678" WantedValue="AndiG" Lots of stuff </XML File> \bWantedValue="([^"]*) AndiG
Full Cookie Text: RegEx: Returns:
VALUE_A=Stuff; JSESSIONID=f423cc8100ab1990e70e4c34c4d8; JROUTE=HZrB;MORECOOKIES
JSESSIONID=([\w]\*)
f423cc8100ab1990e70e4c34c4d8

Parsing header/session/cookie/attrib

Just plug in (.*)

Full Method Argument: RegEx: Returns:
AUTH_USER:domain/user@emailaddr.com domain/(.*)       or   domain/(.*)@ user@emailaddr.com or user

The following allows you to extract an email value from a key/value pair where the keyname is userid. This can be used for example when an email is passed in a Cookie.

Full Cookie Text: RegEx: Returns:
somekey=somevalue;userid=community@dynatrace.com
\buserid=([a-zA-Z0-9.\_%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})\b
community@dynatrace.com

Extracting part of a URI

(for example for a Business Transaction Split Measure)

URI: RegEx: Returns:
http://dtstoragetest.blob.core.windows.net/samplecontainer
https?://([^.]*)\.blob\.core\.windows\.net/.*
dtstoragetest

Identify classes ending with a certain string (limited to [cls] or [bas])

Class RegEx
MyClass[cls] or MyOtherClass[bas]
(\[cls\]|\[bas\])

Extract string of a constant length

The following allows you to extract a string that is of 20 character length. The string of interest is the value after corellationid.

Full String Text: RegEx:
>>subtractResult= >>>result=2, corellationid=vamsitest987654321, _env= >>>locale=, tag=166, activation=wm6ed6e9c70-bcc3-11e2-81a2-e32be605e442, corellationid=(.{20})