Splunk Search

regex global modifiers

alon7786
New Member

Hi,

I trying to execute regex in search command with g (global) m (multi-line) s (single-line).
the regular way (?gms) yields g is unknown flag, so I've tried to convert it to sed mode s/(?ms).../replace/g.
Am I missing something?
Is there another way to achieve it?

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Instead of the g modifier, use the max_match option. For example:

... | rex max_match=0 "(?ms)(foo)" | ...

will find all instances of 'foo' in _raw.

That said, replacing rex with sed does something very different. What exactly are you trying to accomplish with rex?

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Instead of the g modifier, use the max_match option. For example:

... | rex max_match=0 "(?ms)(foo)" | ...

will find all instances of 'foo' in _raw.

That said, replacing rex with sed does something very different. What exactly are you trying to accomplish with rex?

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...