Splunk Search
Highlighted

regex exclue from IPs

Path Finder

I have following regex which giving Cisco group name but my events containing group = 132.XX .34.34 some IPS also so i just want to show in new field only actual group name and remove the IP from results. I have tried below one but still showing IP values.

":\s+Group(\s+=\s+|\s+<)(?P[^>|^,]+)"

Group event contains.
Group = xpn
Group = blaa
Group =
Group =
Group = < ter=pan>
Group = 123.23.21.23.

i want remove IPS from my group field.

Tags (1)
0 Karma
Highlighted

Re: regex exclue from IPs

Ultra Champion

First of all: I think your regex needs some work. < and > need to be escaped, and | does not work as an OR operator in the character set definition (the [...] bit). If you want anything but > and ,, just do [^\>,]. You can use tools like regex101.com to validate your regex. If you post some sample data here, people can also help with that.

How easy it is to ignore IP addresses depends on what valid group names look like. Can those start with a number? If not, then it is easy, just add a \D (any non-number character) at the start of the capturing part of your regex, to make it match only group names that don't start with a number.

If they can start with a number, it is a bit more difficult and may be simpler to just capture it incl. IP addresses and then remove anything that looks like an IP address afterwards.

| ...your base search...
| ...your rex command...
| eval Group=if(match(Group, "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"), null(), Group)
0 Karma