Splunk Search

How to create regex to find source path that contains spaces?

sarit_s
Communicator

Hello

I have sources that contain white spaces and I wand to count them

What is the regex to find all the sources with spaces ?

 

Thanks

Labels (2)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| regex source="\s"

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sarit_s ,

to help you, it's manadatory a sample of your logs, anyway, you can use the other chars to extract a regex.

So, if you want to extract the folder from this log:

2023-08-02 host1 11.11.11 10.2.34.12 path="C:\Program Files\folder 1\my_file.docx",

you could try something like this:

| rex "path\=\".*\\(?<folder>[^\\]+)\\\w+\.\w+\""

that you can test at https://regex101.com/r/i6V2W4/1

Ciao.

Giuseppe

0 Karma

sarit_s
Communicator

Hello

Thanks for your reply

this is an example of my path:

C:\Projects\API Managment Logging\Logs\*.txt

 

Also, the regex you attached is invalid 😞

0 Karma

sarit_s
Communicator

also , maybe I wasn't clear enough

I want to count all the hosts that have sources with spaces

I don't want to extract the folder, I just need to know how many sources with white space I have

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sarit_s ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| regex source="\s"
0 Karma
Get Updates on the Splunk Community!

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureOn Demand Now Step boldly into the AI revolution with enhanced security ...