Splunk Search

Regular expression is not working properly.. Please suggest

rajim
Path Finder

I need to have the first qualifier of a FQDN string. I have used the below mentioned query to do so. But it's not recognizing the ".". Could anyone please help me out here.

index=myindex_glbl 
| rex field=Domain "^(?<Territory>.*)\."
| dedup Domain
| table Domain Territory

Here is the sample output:

Domain  Territory
us.nam.ad.xyz.com   us.nam.ad.xyz
crb.nam.ad.xyz.com  crb.nam.ad.xyz

This is very strange behaviour. Can anybody suggest why this is happening?

0 Karma
1 Solution

493669
Super Champion

Try this regex:

| rex field=Domain "^(?<Territory>[^\.]+)"

below regex will check till it found last "." instead of first while above regex will find first "."

| rex field=Domain "^(?<Territory>.*)\."

View solution in original post

493669
Super Champion

Try this regex:

| rex field=Domain "^(?<Territory>[^\.]+)"

below regex will check till it found last "." instead of first while above regex will find first "."

| rex field=Domain "^(?<Territory>.*)\."

rajim
Path Finder

Thanks .. It's working... so if the delimiter character is mentioned after the ")", then it'll search for last occurance, right?

0 Karma

493669
Super Champion

not only when it is mentioned after ")" if you try | rex field=Domain "^(?<Territory>.*\.)" then also it will search for last occurance.

0 Karma

rajim
Path Finder

got it .. thnks.

0 Karma
Get Updates on the Splunk Community!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...