Splunk Search

Regex - Ignore Whitespace

vragosta
Path Finder

Is it possible to create a regex to ignore whitespace? Typically you can use /x to do this, but this does not seem to work in Splunk. I have also tried putting (?x) at the front of the regex, but this fails as well.

So, is there a modifier to ignore whitespace?

Also, is there any good documentation on all of the available regex modifiers within Splunk?

Thanks!

Tags (1)
0 Karma

jonuwz
Influencer

where are the regexes ? in transforms.conf or in the rex search command ? Do you have an example ? how does it fail? Its feasible that transforms.conf is read line by line, so multi-line regexes would be garbled, but id expect errors on splunk start in that case

0 Karma

rgcurry
Contributor

From the Splunk Community Wiki, there is an article about this titled "RegEx Testing Tools" which starts with " Splunk uses Perl compatible regular expressions". This might help you with what you can and cannot use.

Have you tried using "\S+" (note the 's' is capitalized)? How about "(?!\s+)" for a negative lookahead?

Perhaps if you provide an example of your source for which you want this to work, someone can provide a sample RegEx to do what is wanted and needed.

jonuwz
Influencer

(?x) allows you to insert comments into your regex provided they're inbetween character classes examples

0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...