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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...