cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

Regex replace syntax?

ulf_thornander3
Inactive

Hi

In a SOA oriented DC with lots of SOAP and XML calls crisscrossing, there are UserID's of internal users and they are handled. But there are also calls from Anonymous users on the public facing site. These IDs get created with a GUID like a461763b-f011-4a8d-8c19-65578366430d and each session gets a new GUID. This is not nice to the database or to the people trying to understand reports.

Therefore I'm trying to make a Regex that would replace any string with a text string like "Guest".

I've tried a couple of basic and advanced as well as PERL based Regex's but none of them seem to do the trick. I'll happily test anything you can come up with 🙂

4 REPLIES 4

wojciech_kurek
Inactive

Ulf,

The regexes can only be used to extract part of the value seen in the traffic, they cannot be used for value substitution. The only thing that could be done on the AMD would be defining a regex that wouldn't accept those GUIDs at all, leaving an empty username for anonymous users. Depending on how the regular usernames look like, the regex could for example accept anything that doesn't have a dash (provided, that normal usernames don't contain it):

^\([^-]*\)$

A different solution could consist of changing the usernames on CAS (I believe it supports custom username mapping classes).

W.

Hi W.

The TAG I'm picking gives the unique GUID

Some "internal magic" does some Regex on this as it gets presented as

Which in most cases would be what you wanted, but in this case it just creates endless "UserID"s without any real value.

If I try another approach and wildcard the TAG I end up with the "true" string which is what I have tried to alter by replacing text and this is what I have failed in.

My hope here was to try and scale it back to only being "ConsumerSession" or even a part of the URL.

wojciech_kurek
Inactive

You can try the following regex:

${perl}##(ConsumerSession).*[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}.*|>([^<]+)<

It should report the "ConsumerSession" string in case the username is a GUID and the actual username if it's not a GUID. It will work, provided that the GUID format consists of 5 hyphen separated hexadecimal character sequences with the following lengths: 8, 4, 4, 4, 12 (from your screenshot it appears the GUID format is just that).

Wojtek.

For some reason, the regex breaks the RUM Console regex tester (fails with an "Error null" message 😉 ), but it works on the AMD.